Struct RawChunk

Source
pub struct RawChunk<D = Vec<u8>> { /* private fields */ }
Expand description

Represents a raw chunk

Implementations§

Source§

impl RawChunk

Source

pub fn from_data<T: Into<Vec<u8>>>(ty: ChunkType, data: T) -> Self

Create a new RawChunk from given ChunkType and bytes.

§Examples
use libpna::{prelude::*, ChunkType, RawChunk};

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<T: AsRef<[u8]>> Chunk for RawChunk<T>

Source§

fn length(&self) -> u32

Length of data in bytes.
Source§

fn ty(&self) -> ChunkType

Type of chunk.
Source§

fn data(&self) -> &[u8]

Data of chunk.
Source§

fn crc(&self) -> u32

CRC32 of chunk type and data.
Source§

impl<D: Clone> Clone for RawChunk<D>

Source§

fn clone(&self) -> RawChunk<D>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug> Debug for RawChunk<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D> From<(ChunkType, D)> for RawChunk<D>
where (ChunkType, D): Chunk,

Source§

fn from(value: (ChunkType, D)) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<RawChunk<&'a [u8]>> for RawChunk<Vec<u8>>

Source§

fn from(value: RawChunk<&'a [u8]>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<RawChunk<&'a [u8]>> for RawChunk<Cow<'a, [u8]>>

Source§

fn from(value: RawChunk<&'a [u8]>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<RawChunk<Cow<'a, [u8]>>> for RawChunk<Vec<u8>>

Source§

fn from(value: RawChunk<Cow<'a, [u8]>>) -> Self

Converts to this type from the input type.
Source§

impl From<RawChunk> for RawChunk<Cow<'_, [u8]>>

Source§

fn from(value: RawChunk<Vec<u8>>) -> Self

Converts to this type from the input type.
Source§

impl<D: Hash> Hash for RawChunk<D>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<D: Ord> Ord for RawChunk<D>

Source§

fn cmp(&self, other: &RawChunk<D>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<D: PartialEq> PartialEq for RawChunk<D>

Source§

fn eq(&self, other: &RawChunk<D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: PartialOrd> PartialOrd for RawChunk<D>

Source§

fn partial_cmp(&self, other: &RawChunk<D>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<D: Eq> Eq for RawChunk<D>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V