pub struct Length(pub u32);
Expand description
A type for representing data set content length, in bytes.
An internal value of 0xFFFF_FFFF
represents an undefined
(unspecified) length, which would have to be determined
with a traversal based on the content’s encoding.
This also means that numeric comparisons and arithmetic do not function the same way as primitive number types:
Two length of undefined length are not equal.
assert_ne!(Length::UNDEFINED, Length::UNDEFINED);
Any addition or subtraction with at least one undefined length results in an undefined length.
assert!((Length::defined(64) + Length::UNDEFINED).is_undefined());
assert!((Length::UNDEFINED + 8).is_undefined());
Comparing between at least one undefined length is always false
.
assert!(Length::defined(16) < Length::defined(64));
assert!(!(Length::UNDEFINED < Length::defined(64)));
assert!(!(Length::UNDEFINED > Length::defined(64)));
assert!(!(Length::UNDEFINED < Length::UNDEFINED));
assert!(!(Length::UNDEFINED > Length::UNDEFINED));
assert!(!(Length::UNDEFINED <= Length::UNDEFINED));
assert!(!(Length::UNDEFINED >= Length::UNDEFINED));
Tuple Fields§
§0: u32
Implementations§
Source§impl Length
impl Length
Source§impl Length
impl Length
Sourcepub fn is_undefined(self) -> bool
pub fn is_undefined(self) -> bool
Check whether this length is undefined (unknown).
Sourcepub fn is_defined(self) -> bool
pub fn is_defined(self) -> bool
Check whether this length is well defined (not undefined).
Trait Implementations§
Source§impl PartialOrd for Length
impl PartialOrd for Length
Source§impl SubAssign<i32> for Length
impl SubAssign<i32> for Length
Source§fn sub_assign(&mut self, rhs: i32)
fn sub_assign(&mut self, rhs: i32)
Performs the
-=
operation. Read moreSource§impl SubAssign for Length
impl SubAssign for Length
Source§fn sub_assign(&mut self, rhs: Length)
fn sub_assign(&mut self, rhs: Length)
Performs the
-=
operation. Read moreimpl Copy for Length
Auto Trait Implementations§
impl Freeze for Length
impl RefUnwindSafe for Length
impl Send for Length
impl Sync for Length
impl Unpin for Length
impl UnwindSafe for Length
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
)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