Skip to main content

BaseModel

Trait BaseModel 

Source
pub trait BaseModel: Serialize + DeserializeOwned {
    const NAME: &'static str;

    // Required methods
    fn get_extension_list() -> &'static ModelExtensionList;
    fn get_extension_data(&self) -> &ModelExtensionData;
    fn base_columns(
        prefix: Option<&str>,
    ) -> BTreeMap<&'static str, CompactString>;
    fn map(prefix: Option<&str>, row: &PgRow) -> Result<Self, DatabaseError>;

    // Provided methods
    fn register_model_extension(
        extension: impl ModelExtension + Send + Sync + 'static,
    ) { ... }
    fn parse_model_extension<Extension: SafeModelExtension>(
        &self,
    ) -> Result<Extension::Value, DatabaseError>
       where Extension::Value: Serialize + DeserializeOwned { ... }
    fn columns(prefix: Option<&str>) -> BTreeMap<&'static str, CompactString> { ... }
    fn columns_sql(prefix: Option<&str>) -> CompactString { ... }
    fn map_extensions(
        prefix: &str,
        row: &PgRow,
    ) -> Result<ModelExtensionData, DatabaseError> { ... }
}

Required Associated Constants§

Source

const NAME: &'static str

Required Methods§

Source

fn get_extension_list() -> &'static ModelExtensionList

Source

fn get_extension_data(&self) -> &ModelExtensionData

Source

fn base_columns(prefix: Option<&str>) -> BTreeMap<&'static str, CompactString>

Source

fn map(prefix: Option<&str>, row: &PgRow) -> Result<Self, DatabaseError>

Provided Methods§

Source

fn register_model_extension( extension: impl ModelExtension + Send + Sync + 'static, )

Registers a model extension. If an extension with the same name is already registered, this function will do nothing.

Source

fn parse_model_extension<Extension: SafeModelExtension>( &self, ) -> Result<Extension::Value, DatabaseError>
where Extension::Value: Serialize + DeserializeOwned,

Parses a model extension from the model’s extension data. If the extension is not found, or if the data cannot be deserialized, an error is returned.

This can be costly depending on what is stored, so use sparingly.

Source

fn columns(prefix: Option<&str>) -> BTreeMap<&'static str, CompactString>

Source

fn columns_sql(prefix: Option<&str>) -> CompactString

Source

fn map_extensions( prefix: &str, row: &PgRow, ) -> Result<ModelExtensionData, DatabaseError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl BaseModel for AdminActivity

Source§

const NAME: &'static str = "admin_activity"

Source§

impl BaseModel for Announcement

Source§

const NAME: &'static str = "announcement"

Source§

impl BaseModel for BackupConfiguration

Source§

const NAME: &'static str = "backup_configuration"

Source§

impl BaseModel for DatabaseHost

Source§

const NAME: &'static str = "database_host"

Source§

impl BaseModel for EggConfiguration

Source§

const NAME: &'static str = "egg_configuration"

Source§

impl BaseModel for EggRepository

Source§

const NAME: &'static str = "egg_repository"

Source§

impl BaseModel for EggRepositoryEgg

Source§

const NAME: &'static str = "egg_repository_egg"

Source§

impl BaseModel for Location

Source§

const NAME: &'static str = "location"

Source§

impl BaseModel for LocationDatabaseHost

Source§

const NAME: &'static str = "location_database_host"

Source§

impl BaseModel for Mount

Source§

const NAME: &'static str = "mount"

Source§

impl BaseModel for Nest

Source§

const NAME: &'static str = "nest"

Source§

impl BaseModel for NestEgg

Source§

const NAME: &'static str = "nest_egg"

Source§

impl BaseModel for NestEggMount

Source§

const NAME: &'static str = "nest_egg_mount"

Source§

impl BaseModel for NestEggVariable

Source§

const NAME: &'static str = "nest_egg_variable"

Source§

impl BaseModel for Node

Source§

const NAME: &'static str = "node"

Source§

impl BaseModel for NodeAllocation

Source§

const NAME: &'static str = "node_allocation"

Source§

impl BaseModel for NodeMount

Source§

const NAME: &'static str = "node_mount"

Source§

impl BaseModel for OAuthProvider

Source§

const NAME: &'static str = "oauth_provider"

Source§

impl BaseModel for Role

Source§

const NAME: &'static str = "role"

Source§

impl BaseModel for Server

Source§

const NAME: &'static str = "server"

Source§

impl BaseModel for ServerActivity

Source§

const NAME: &'static str = "server_activity"

Source§

impl BaseModel for ServerAllocation

Source§

const NAME: &'static str = "server_allocation"

Source§

impl BaseModel for ServerBackup

Source§

const NAME: &'static str = "server_backup"

Source§

impl BaseModel for ServerDatabase

Source§

const NAME: &'static str = "server_database"

Source§

impl BaseModel for ServerMount

Source§

const NAME: &'static str = "server_mount"

Source§

impl BaseModel for ServerSchedule

Source§

const NAME: &'static str = "server_schedule"

Source§

impl BaseModel for ServerScheduleStep

Source§

const NAME: &'static str = "server_schedule_step"

Source§

impl BaseModel for ServerSubuser

Source§

const NAME: &'static str = "server_subuser"

Source§

impl BaseModel for ServerVariable

Source§

const NAME: &'static str = "server_variable"

Source§

impl BaseModel for User

Source§

const NAME: &'static str = "user"

Source§

impl BaseModel for UserActivity

Source§

const NAME: &'static str = "user_activity"

Source§

impl BaseModel for UserApiKey

Source§

const NAME: &'static str = "user_api_key"

Source§

impl BaseModel for UserCommandSnippet

Source§

const NAME: &'static str = "user_command_snippet"

Source§

const NAME: &'static str = "user_oauth_link"

Source§

impl BaseModel for UserPasswordReset

Source§

const NAME: &'static str = "user_password_reset"

Source§

impl BaseModel for UserRecoveryCode

Source§

const NAME: &'static str = "user_recovery_code"

Source§

impl BaseModel for UserSecurityKey

Source§

const NAME: &'static str = "user_security_key"

Source§

impl BaseModel for UserServerGroup

Source§

const NAME: &'static str = "user_server_group"

Source§

impl BaseModel for UserSession

Source§

const NAME: &'static str = "user_session"

Source§

impl BaseModel for UserSshKey

Source§

const NAME: &'static str = "user_ssh_key"