Trait Primitive

Source
pub trait Primitive:
    'static
    + Default
    + Send
    + Sync {
    type A: Atom;

    const DTYPE: DataType;
    const IS_ATOMIC: bool;

    // Required methods
    fn to_value(&self) -> Value;
    fn try_from_value(v: &Value) -> CoreResult<Self>
       where Self: Sized;
    fn to_atoms(&self) -> Vec<Self::A>;
    fn try_from_atoms(atoms: &[Self::A]) -> CoreResult<Self>
       where Self: Sized;
    fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>;

    // Provided method
    fn new_value_codec(codec: &str) -> Option<Box<dyn ValueCodec>>
       where Self: Sized { ... }
}

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn to_value(&self) -> Value

Source

fn try_from_value(v: &Value) -> CoreResult<Self>
where Self: Sized,

Source

fn to_atoms(&self) -> Vec<Self::A>

Source

fn try_from_atoms(atoms: &[Self::A]) -> CoreResult<Self>
where Self: Sized,

Source

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Provided Methods§

Source

fn new_value_codec(codec: &str) -> Option<Box<dyn ValueCodec>>
where Self: Sized,

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.

Implementations on Foreign Types§

Source§

impl Primitive for bool

Source§

const DTYPE: DataType = DataType::Bool

Source§

const IS_ATOMIC: bool = true

Source§

type A = bool

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<bool>

Source§

fn to_atoms(&self) -> Vec<Self>

Source§

fn try_from_atoms(atoms: &[Self]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Source§

impl Primitive for f32

Source§

const DTYPE: DataType = DataType::Float32

Source§

const IS_ATOMIC: bool = true

Source§

type A = f32

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<f32>

Source§

fn to_atoms(&self) -> Vec<Self>

Source§

fn try_from_atoms(atoms: &[Self]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Source§

impl Primitive for f64

Source§

const DTYPE: DataType = DataType::Float64

Source§

const IS_ATOMIC: bool = true

Source§

type A = f64

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<f64>

Source§

fn to_atoms(&self) -> Vec<Self>

Source§

fn try_from_atoms(atoms: &[Self]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Source§

impl Primitive for i64

Source§

const DTYPE: DataType = DataType::Int64

Source§

const IS_ATOMIC: bool = true

Source§

type A = i64

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<i64>

Source§

fn to_atoms(&self) -> Vec<Self>

Source§

fn try_from_atoms(atoms: &[Self]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Source§

impl Primitive for String

Source§

const DTYPE: DataType = DataType::String

Source§

const IS_ATOMIC: bool = false

Source§

type A = u8

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<String>

Source§

fn to_atoms(&self) -> Vec<u8>

Source§

fn try_from_atoms(atoms: &[u8]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Source§

impl Primitive for Vec<u8>

Source§

const DTYPE: DataType = DataType::Bytes

Source§

const IS_ATOMIC: bool = false

Source§

type A = u8

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<Vec<u8>>

Source§

fn to_atoms(&self) -> Vec<u8>

Source§

fn try_from_atoms(atoms: &[u8]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Source§

impl Primitive for TimestampMicros

Source§

const DTYPE: DataType = DataType::TimestampMicros

Source§

const IS_ATOMIC: bool = true

Source§

type A = TimestampMicros

Source§

fn to_value(&self) -> Value

Source§

fn try_from_value(v: &Value) -> CoreResult<TimestampMicros>

Source§

fn to_atoms(&self) -> Vec<Self>

Source§

fn try_from_atoms(atoms: &[Self]) -> CoreResult<Self>

Source§

fn new_codec(codec: &str) -> Option<Box<dyn Codec<P = Self>>>

Implementors§