pub struct GenericCard<F: CardFormat> {
pub header: GenericHeader,
pub metadata: GenericMetadata,
pub payload: Vec<u8>,
/* private fields */
}Expand description
Generic card that works with any CardFormat
Fields§
§header: GenericHeaderCard header
metadata: GenericMetadataCard metadata
payload: Vec<u8>Raw payload bytes
Implementations§
Source§impl<F: CardFormat> GenericCard<F>
impl<F: CardFormat> GenericCard<F>
Sourcepub fn new_with_checksum(id: impl Into<String>, payload: Vec<u8>) -> Self
pub fn new_with_checksum(id: impl Into<String>, payload: Vec<u8>) -> Self
Create a new card with checksum
Sourcepub fn from_parts(metadata: GenericMetadata, payload: Vec<u8>) -> Result<Self>
pub fn from_parts(metadata: GenericMetadata, payload: Vec<u8>) -> Result<Self>
Create from metadata and payload
Sourcepub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
Load card from file
The .card extension is added automatically - do NOT include it in the path.
Sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save card to file
The .card extension is added automatically - do NOT include it in the path.
Sourcepub fn calculate_checksum(&self) -> u32
pub fn calculate_checksum(&self) -> u32
Calculate CRC32 checksum
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize from bytes
Sourcepub fn has_checksum(&self) -> bool
pub fn has_checksum(&self) -> bool
Check if card has checksum
Trait Implementations§
Source§impl<F: Clone + CardFormat> Clone for GenericCard<F>
impl<F: Clone + CardFormat> Clone for GenericCard<F>
Source§fn clone(&self) -> GenericCard<F>
fn clone(&self) -> GenericCard<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<F> Freeze for GenericCard<F>
impl<F> RefUnwindSafe for GenericCard<F>where
F: RefUnwindSafe,
impl<F> Send for GenericCard<F>where
F: Send,
impl<F> Sync for GenericCard<F>where
F: Sync,
impl<F> Unpin for GenericCard<F>where
F: Unpin,
impl<F> UnwindSafe for GenericCard<F>where
F: UnwindSafe,
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