pub struct ChunkType(/* private fields */);Expand description
A 4-byte chunk type code.
Implementations§
source§impl ChunkType
impl ChunkType
sourcepub fn private(ty: [u8; 4]) -> Result<Self, ChunkTypeError>
pub fn private(ty: [u8; 4]) -> Result<Self, ChunkTypeError>
Creates private ChunkType.
§Errors
This function will return an error in the following cases:
- Value contains non-ASCII alphabet characters
- The second character is not lowercase
- The third character is not uppercase
§Examples
assert!(ChunkType::private(*b"myTy").is_ok());
assert_eq!(
ChunkType::private(*b"zeR\0").unwrap_err(),
ChunkTypeError::NonAsciiAlphabetic
);
assert_eq!(
ChunkType::private(*b"pRIv").unwrap_err(),
ChunkTypeError::NonPrivateChunkType
);
assert_eq!(
ChunkType::private(*b"rese").unwrap_err(),
ChunkTypeError::Reserved
);sourcepub const unsafe fn from_unchecked(ty: [u8; 4]) -> Self
pub const unsafe fn from_unchecked(ty: [u8; 4]) -> Self
Creates custom ChunkType without any check.
§Panic
Printing ChunkType that contains non-utf8 characters will be panicked.
let custom_chunk_type = unsafe { ChunkType::from_unchecked([0xe3, 0x81, 0x82, 0xe3]) };
format!("{}", custom_chunk_type);§Safety
Safe when value consists only of ascii alphabetic characters (‘a’…‘z’ and ‘A’…‘Z’).
let custom_chunk_type = unsafe { ChunkType::from_unchecked(*b"myTy") };
format!("{}", custom_chunk_type);Trait Implementations§
source§impl Ord for ChunkType
impl Ord for ChunkType
source§impl PartialOrd for ChunkType
impl PartialOrd for ChunkType
impl Copy for ChunkType
impl Eq for ChunkType
impl StructuralPartialEq for ChunkType
Auto Trait Implementations§
impl Freeze for ChunkType
impl RefUnwindSafe for ChunkType
impl Send for ChunkType
impl Sync for ChunkType
impl Unpin for ChunkType
impl UnwindSafe for ChunkType
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)