pub struct RawChunk<D = Vec<u8>> { /* private fields */ }Expand description
A raw chunk in a PNA archive.
This structure represents a chunk in its most basic form, containing:
length: The length of the chunk data in bytesty: The type of the chunk (e.g., FDAT, SDAT, etc.)data: The actual chunk datacrc: A CRC32 checksum of the chunk type and data
§Examples
use libpna::{ChunkType, RawChunk, prelude::*};
// Create a new chunk with some data
let data = [0xAA, 0xBB, 0xCC, 0xDD];
let chunk = RawChunk::from_data(ChunkType::FDAT, data);
// Access chunk properties
assert_eq!(chunk.length(), 4);
assert_eq!(chunk.ty(), ChunkType::FDAT);
assert_eq!(chunk.data(), &[0xAA, 0xBB, 0xCC, 0xDD]);
assert_eq!(chunk.crc(), 1207118608);Implementations§
Source§impl RawChunk
impl RawChunk
Sourcepub fn from_data<T>(ty: ChunkType, data: T) -> RawChunk
pub fn from_data<T>(ty: ChunkType, data: T) -> RawChunk
Creates a new RawChunk from the given ChunkType and bytes.
§Examples
use libpna::{ChunkType, RawChunk, prelude::*};
let data = [0xAA, 0xBB, 0xCC, 0xDD];
let chunk = RawChunk::from_data(ChunkType::FDAT, data);
assert_eq!(chunk.length(), 4);
assert_eq!(chunk.ty(), ChunkType::FDAT);
assert_eq!(chunk.data(), &[0xAA, 0xBB, 0xCC, 0xDD]);
assert_eq!(chunk.crc(), 1207118608);Trait Implementations§
Source§impl<D> Ord for RawChunk<D>where
D: Ord,
impl<D> Ord for RawChunk<D>where
D: Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<D> PartialOrd for RawChunk<D>where
D: PartialOrd,
impl<D> PartialOrd for RawChunk<D>where
D: PartialOrd,
impl<D> Eq for RawChunk<D>where
D: Eq,
impl<D> StructuralPartialEq for RawChunk<D>
Auto Trait Implementations§
impl<D> Freeze for RawChunk<D>where
D: Freeze,
impl<D> RefUnwindSafe for RawChunk<D>where
D: RefUnwindSafe,
impl<D> Send for RawChunk<D>where
D: Send,
impl<D> Sync for RawChunk<D>where
D: Sync,
impl<D> Unpin for RawChunk<D>where
D: Unpin,
impl<D> UnwindSafe for RawChunk<D>where
D: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more