Trait abd_clam::Instance

source ·
pub trait Instance: Debug + Send + Sync + Clone {
    // Required methods
    fn to_bytes(&self) -> Vec<u8>;
    fn from_bytes(bytes: &[u8]) -> Result<Self, String>
       where Self: Sized;
    fn type_name() -> String;

    // Provided methods
    fn save<W: Write>(&self, writer: &mut W) -> Result<(), String> { ... }
    fn load<R: Read>(reader: &mut R) -> Result<Self, String>
       where Self: Sized { ... }
}
Expand description

Trait for individual data points.

Required Methods§

source

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

Convert the instance to a byte vector.

source

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

Convert a byte vector to an instance.

§Errors

If the byte vector cannot be parsed into an instance.

source

fn type_name() -> String

The name of the type of instance.

Provided Methods§

source

fn save<W: Write>(&self, writer: &mut W) -> Result<(), String>

Save the instance to a file.

§Errors

If the file cannot be written to.

source

fn load<R: Read>(reader: &mut R) -> Result<Self, String>
where Self: Sized,

Load the instance from a file.

§Errors

If the file cannot be read or the instance cannot be parsed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Instance for bool

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for f32

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for f64

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for i8

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for i16

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for i32

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for i64

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for i128

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for isize

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for u8

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for u16

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for u32

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for u64

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for u128

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for usize

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>
where Self: Sized,

source§

fn type_name() -> String

source§

impl Instance for String

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>

source§

fn type_name() -> String

source§

impl<T: Number> Instance for Vec<T>

source§

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

source§

fn from_bytes(bytes: &[u8]) -> Result<Self, String>

source§

fn type_name() -> String

Implementors§