Expand description
§sea-orm-newtype
This crate provides helper derive macro to implement new-type pattern for sea-orm.
§Example
use std::marker::PhantomData;
use uuid::Uuid;
use sea_orm_newtype::DeriveNewType;
/// New type for id that has specific type.
#[derive(Debug, Clone, PartialEq, DeriveNewType)]
#[sea_orm_newtype(from_into = "Uuid", primary_key)]
pub struct Id<T>(Uuid, PhantomData<T>);
impl<T> From<Uuid> for Id<T> {
fn from(id: Uuid) -> Id<T> {
Id(id, PhantomData)
}
}
impl<T> From<Id<T>> for Uuid {
fn from(value: Id<T>) -> Self {
value.0
}
}Re-exports§
Enums§
- Value
- Value variants
Traits§
- Nullable
- TryFrom
U64 - Try to convert a type to a u64
- TryGetable
- An interface to get a value from the query result
- Value
Type
Derive Macros§
- Derive
NewType - derive macro to implement new-type pattern for sea-orm. Derive some traits to use in sea-orm. By default, the following traits are implemented.