citadel_sdk::prelude

Trait SyncIO

pub trait SyncIO {
    // Provided methods
    fn serialize_to_vector(&self) -> Result<Vec<u8>, AccountError>
       where Self: Serialize { ... }
    fn deserialize_from_vector<'a>(
        input: &'a [u8],
    ) -> Result<Self, AccountError>
       where Self: Deserialize<'a> { ... }
    fn deserialize_from_owned_vector(
        input: Vec<u8>,
    ) -> Result<Self, AccountError>
       where Self: DeserializeOwned { ... }
    fn deserialize_in_place<'a, R, T>(
        reader: R,
        place: &mut T,
    ) -> Result<(), AccountError>
       where T: Deserialize<'a>,
             R: BincodeRead<'a> { ... }
    fn serialize_into_buf(&self, buf: &mut BytesMut) -> Result<(), AccountError>
       where Self: Serialize { ... }
    fn serialize_into_slice(&self, slice: &mut [u8]) -> Result<(), AccountError>
       where Self: Serialize { ... }
    fn serialized_size(&self) -> Option<usize>
       where Self: Serialize { ... }
}
Expand description

Convenient serialization methods for types that #[derive(Serialize, Deserialize)]

Provided Methods§

fn serialize_to_vector(&self) -> Result<Vec<u8>, AccountError>
where Self: Serialize,

Serializes a bincode type to a byte vector

fn deserialize_from_vector<'a>(input: &'a [u8]) -> Result<Self, AccountError>
where Self: Deserialize<'a>,

Deserialized a bincode type from a byte vector

fn deserialize_from_owned_vector(input: Vec<u8>) -> Result<Self, AccountError>
where Self: DeserializeOwned,

Deserializes from an owned buffer

fn deserialize_in_place<'a, R, T>( reader: R, place: &mut T, ) -> Result<(), AccountError>
where T: Deserialize<'a>, R: BincodeRead<'a>,

Deserializes in-place

fn serialize_into_buf(&self, buf: &mut BytesMut) -> Result<(), AccountError>
where Self: Serialize,

Serializes self into a buffer

fn serialize_into_slice(&self, slice: &mut [u8]) -> Result<(), AccountError>
where Self: Serialize,

Serializes directly into a slice

fn serialized_size(&self) -> Option<usize>
where Self: Serialize,

Returns the expected size of the serialized objects

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§

§

impl<'a, T> SyncIO for T
where T: Serialize + Deserialize<'a>,