Skip to main content

Resource

Trait Resource 

Source
pub trait Resource:
    Serialize
    + DeserializeOwned
    + Send
    + Sync
    + Clone
    + 'static {
    type PrimaryKey: Display + DeserializeOwned + Send + Sync;
    type DataLayer: DataLayer<Self>;

    const NAME: &'static [&'static str];
    const PRIMARY_KEY_GENERATED: bool;

    // Required method
    fn primary_key(&self) -> &Self::PrimaryKey;
}
Expand description

Marker trait for a resource.

Required Associated Constants§

Source

const NAME: &'static [&'static str]

Name with namespace of the resource. Each part of the array is a segment in the name (i.e. MyApp.Blog.Post).

Source

const PRIMARY_KEY_GENERATED: bool

Wether the primary key of the resource is generated

Required Associated Types§

Source

type PrimaryKey: Display + DeserializeOwned + Send + Sync

Primary key type of the resource. Usually the type of the id for the resource.

Source

type DataLayer: DataLayer<Self>

Data layer that the resource uses.

Required Methods§

Source

fn primary_key(&self) -> &Self::PrimaryKey

Mathos that returns the primary key of the resource

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§