Trait nuts_backend::Binary

source ·
pub trait Binary
where Self: Sized,
{ // Required methods fn from_bytes(bytes: &[u8]) -> Option<Self>; fn as_bytes(&self) -> Vec<u8>; }
Expand description

Trait for binary conversion.

  • Self::as_bytes is used to create a binary representation of this instance.
  • The Self::from_bytes method is used to convert the binary data back to its instance.

Required Methods§

source

fn from_bytes(bytes: &[u8]) -> Option<Self>

Creates an instance of Self based on its binary representation.

On success an instance of Self wrapped into a Some is returned. On any error None is returned.

source

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

Creates the binary representation of self.

Object Safety§

This trait is not object safe.

Implementors§