Trait SerializableId

Source
pub trait SerializableId: Clone {
    // Required methods
    fn try_create(id: impl Into<String>) -> Result<Self, Error>
       where Self: Sized;
    fn as_str(&self) -> &str;
    fn id(&self) -> String;
    fn key(&self) -> &'static str;
}
Expand description

This trait is for serializing ID to JSON.

It also has some getter functions.

Required Methods§

Source

fn try_create(id: impl Into<String>) -> Result<Self, Error>
where Self: Sized,

Try to create an instance of SerializableId with String parameter.

It returns None, if id is None.

Source

fn as_str(&self) -> &str

Get internal str of the Id.

Source

fn id(&self) -> String

Get internal String of the Id

Source

fn key(&self) -> &'static str

Field name of Json. If it returns "hoge_id", json will be {"hoge_id": self.id()}.

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§