pub struct CRFrame {
pub index: HashMap<String, (u64, CRFrameObjectType)>,
pub bytestorage: Vec<u8>,
}
Expand description
The central data container of the caraspace suite.
A CRFrame can hold multiple CRFrameObjects and is basically a little sclerite of the entire skeleton.
Fields§
§index: HashMap<String, (u64, CRFrameObjectType)>
§bytestorage: Vec<u8>
Implementations§
Source§impl CRFrame
impl CRFrame
pub fn new() -> Self
pub fn serialize_index(&self) -> Vec<u8> ⓘ
pub fn parse_index( stream: &Vec<u8>, pos: &mut usize, ) -> HashMap<String, (u64, CRFrameObjectType)>
Sourcepub fn put<T: CRSerializeable + Frameable>(&mut self, object: T, name: String)
pub fn put<T: CRSerializeable + Frameable>(&mut self, object: T, name: String)
Store any eligible object in the frame
Eligible object must implement the “Frameable” trait
Sourcepub fn has(&self, name: &str) -> bool
pub fn has(&self, name: &str) -> bool
Check if the frame contains an object with the given name
§Arguments:
- name : The name of the object as it appears in the index
pub fn get_fobject( &self, name: &str, ) -> Result<CRFrameObject, CRSerializationError>
pub fn get<T: CRSerializeable + Frameable>( &self, name: String, ) -> Result<T, CRSerializationError>
Sourcepub fn show_frame(&self) -> String
pub fn show_frame(&self) -> String
A verbose display of the frame content
Trait Implementations§
Source§impl CRSerializeable for CRFrame
impl CRSerializeable for CRFrame
Source§fn deserialize(
stream: &Vec<u8>,
pos: &mut usize,
) -> Result<Self, CRSerializationError>
fn deserialize( stream: &Vec<u8>, pos: &mut usize, ) -> Result<Self, CRSerializationError>
Decode a serializable from a bytestream
const CRHEAD: u16 = 43_690u16
const CRTAIL: u16 = 21_845u16
Source§const CRSIZE: usize = 0usize
const CRSIZE: usize = 0usize
The SIZE is the size of the serialized
bytestream INCLUDING 4 bytes for head
and tail bytes. In case the struct does
NOT HAVE a fixed size, SIZE will be 0
(so default value of the trait
Source§fn verify_fixed(
stream: &Vec<u8>,
pos: &mut usize,
) -> Result<(), CRSerializationError>
fn verify_fixed( stream: &Vec<u8>, pos: &mut usize, ) -> Result<(), CRSerializationError>
Verify that the serialized representation of the struct has the
correct size, including header + footer. Read more
Auto Trait Implementations§
impl Freeze for CRFrame
impl RefUnwindSafe for CRFrame
impl Send for CRFrame
impl Sync for CRFrame
impl Unpin for CRFrame
impl UnwindSafe for CRFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more