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§
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§
Sourcefn register_model_extension(
extension: impl ModelExtension + Send + Sync + 'static,
)
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.
Sourcefn parse_model_extension<Extension: SafeModelExtension>(
&self,
) -> Result<Extension::Value, DatabaseError>
fn parse_model_extension<Extension: SafeModelExtension>( &self, ) -> Result<Extension::Value, DatabaseError>
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.
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>
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.