#[non_exhaustive]pub enum PStringLengthWidth {
OneByte,
TwoByteBE,
TwoByteLE,
FourByteBE,
FourByteLE,
}Expand description
The width of the length prefix for Pascal strings.
Uppercase suffix letters (/H, /L) indicate big-endian byte order.
Lowercase suffix letters (/h, /l) indicate little-endian byte order.
§Examples
use libmagic_rs::parser::ast::PStringLengthWidth;
let width = PStringLengthWidth::OneByte;
assert_eq!(width.byte_count(), 1);
let width = PStringLengthWidth::TwoByteBE;
assert_eq!(width.byte_count(), 2);
let width = PStringLengthWidth::FourByteLE;
assert_eq!(width.byte_count(), 4);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
OneByte
1-byte length prefix (default, /B suffix)
§Examples
use libmagic_rs::parser::ast::PStringLengthWidth;
let width = PStringLengthWidth::OneByte;
assert_eq!(width.byte_count(), 1);TwoByteBE
2-byte big-endian length prefix (/H suffix)
§Examples
use libmagic_rs::parser::ast::PStringLengthWidth;
let width = PStringLengthWidth::TwoByteBE;
assert_eq!(width.byte_count(), 2);TwoByteLE
2-byte little-endian length prefix (/h suffix)
§Examples
use libmagic_rs::parser::ast::PStringLengthWidth;
let width = PStringLengthWidth::TwoByteLE;
assert_eq!(width.byte_count(), 2);FourByteBE
4-byte big-endian length prefix (/L suffix)
§Examples
use libmagic_rs::parser::ast::PStringLengthWidth;
let width = PStringLengthWidth::FourByteBE;
assert_eq!(width.byte_count(), 4);FourByteLE
4-byte little-endian length prefix (/l suffix)
§Examples
use libmagic_rs::parser::ast::PStringLengthWidth;
let width = PStringLengthWidth::FourByteLE;
assert_eq!(width.byte_count(), 4);Implementations§
Source§impl PStringLengthWidth
impl PStringLengthWidth
Sourcepub fn byte_count(&self) -> usize
pub fn byte_count(&self) -> usize
Returns the number of bytes used for the length prefix.
Trait Implementations§
Source§impl Clone for PStringLengthWidth
impl Clone for PStringLengthWidth
Source§fn clone(&self) -> PStringLengthWidth
fn clone(&self) -> PStringLengthWidth
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 moreSource§impl Debug for PStringLengthWidth
impl Debug for PStringLengthWidth
Source§impl<'de> Deserialize<'de> for PStringLengthWidth
impl<'de> Deserialize<'de> for PStringLengthWidth
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for PStringLengthWidth
impl PartialEq for PStringLengthWidth
Source§impl Serialize for PStringLengthWidth
impl Serialize for PStringLengthWidth
impl Copy for PStringLengthWidth
impl Eq for PStringLengthWidth
impl StructuralPartialEq for PStringLengthWidth
Auto Trait Implementations§
impl Freeze for PStringLengthWidth
impl RefUnwindSafe for PStringLengthWidth
impl Send for PStringLengthWidth
impl Sync for PStringLengthWidth
impl Unpin for PStringLengthWidth
impl UnsafeUnpin for PStringLengthWidth
impl UnwindSafe for PStringLengthWidth
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