Struct dicom_core::header::Length [−][src]
pub struct Length(pub u32);
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));
Implementations
impl Length[src]
impl Length[src]pub const UNDEFINED: Self[src]
A length that is undefined.
pub fn new(len: u32) -> Self[src]
Create a new length value from its internal representation.
This is equivalent to Length(len).
pub fn defined(len: u32) -> Self[src]
Create a new length value with the given number of bytes.
Panic
This function will panic if len represents an undefined length.
impl Length[src]
impl Length[src]pub fn is_undefined(self) -> bool[src]
Check whether this length is undefined (unknown).
pub fn is_defined(self) -> bool[src]
Check whether this length is well defined (not undefined).
pub fn get(self) -> Option<u32>[src]
Fetch the concrete length value, if available.
Returns None if it represents an undefined length.
pub fn inner_eq(self, other: Length) -> bool[src]
Check whether the length is equally specified as another length.
Unlike the implemented PartialEq, two undefined lengths are
considered equivalent by this method.
Trait Implementations
impl PartialOrd<Length> for Length[src]
impl PartialOrd<Length> for Length[src]Auto Trait Implementations
impl RefUnwindSafe for Length
impl RefUnwindSafe for Lengthimpl UnwindSafe for Length
impl UnwindSafe for Length