Skip to main content

NamedType

Trait NamedType 

Source
pub trait NamedType: Sized {
    type Stored: Schema;

    const NAME: &'static str;

    // Required methods
    fn to_stored(&self) -> Self::Stored;
    fn from_stored(stored: Self::Stored) -> Option<Self>;
}
Expand description

A type of a format’s own, stored as NamedType::Stored in every form (text, binary, frames) and described by NamedType::NAME, so a tool that knows the name shows its own editor (a colour picker, a calendar) and one that doesn’t edits the stored data. crate::named_schema! implements Schema for it.

Required Associated Constants§

Source

const NAME: &'static str

What tools know it by: "color", "date".

Required Associated Types§

Source

type Stored: Schema

What it’s stored as.

Required Methods§

Source

fn to_stored(&self) -> Self::Stored

Its stored form.

Source

fn from_stored(stored: Self::Stored) -> Option<Self>

The value stored holds, if it’s a valid one.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl NamedType for Color

Source§

const NAME: &'static str = yog_ids::typed::COLOR

Source§

type Stored = Value

Source§

impl NamedType for Image

Source§

const NAME: &'static str = yog_ids::typed::IMAGE

Source§

type Stored = Value

Source§

impl NamedType for Text

Source§

const NAME: &'static str = yog_ids::typed::TEXT

Source§

type Stored = Value

Source§

impl NamedType for Uid

Stored as its hex text everywhere (a tool shows a uid).

Source§

const NAME: &'static str = "uid"

Source§

type Stored = String