Struct dicom_core::header::Length
source · 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 substraction 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 PartialEq for Length
impl PartialEq for Length
source§impl PartialOrd for Length
impl PartialOrd for Length
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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> 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