pub struct OpenFileOptions { /* private fields */ }Expand description
Builder for reading a DICOM file with non-default options (an explicit preamble requirement, or an early-stop tag for partial/fast reads).
Implementations§
Source§impl OpenFileOptions
impl OpenFileOptions
pub fn new() -> Self
pub fn read_preamble(self, mode: ReadPreamble) -> Self
Sourcepub fn read_until(self, tag: Tag) -> Self
pub fn read_until(self, tag: Tag) -> Self
Stop reading as soon as an element with a tag greater than tag is encountered
(inclusive of tag itself) - a fast path for partial/filtered reads that don’t need
the rest of the data set. Matches dcmnorm’s --filter CLI early-stop optimization.
Sourcepub fn flexible_decoding(self, flexible_decoding: bool) -> Self
pub fn flexible_decoding(self, flexible_decoding: bool) -> Self
Detect from the data set itself whether a Little Endian file is encoded with explicit or
implicit VRs, instead of trusting its declared transfer syntax - for non-conformant files
that declare Explicit VR Little Endian but write Implicit VR (see
DataSetReaderOptions::flexible_decoding). Applies to Self::open_file and
Self::from_reader. Off by default.
pub fn open_file( self, path: impl AsRef<Path>, ) -> Result<DefaultDicomObject, ReadError>
pub fn from_reader( self, source: impl Read, ) -> Result<DefaultDicomObject, ReadError>
Sourcepub fn open_file_until_pixel_data(
self,
path: impl AsRef<Path>,
) -> Result<Option<(DefaultDicomObject, PixelDataValueLocation)>, ReadError>
pub fn open_file_until_pixel_data( self, path: impl AsRef<Path>, ) -> Result<Option<(DefaultDicomObject, PixelDataValueLocation)>, ReadError>
Read everything in path up to (not including) a native PixelData value, and report
where that value sits in the file instead of loading it - the building block for reading
one frame of a large multi-frame object (seek to it) without paying for all the others.
Returns Ok(None) whenever this shortcut doesn’t apply and the caller should do a full
read instead: an encapsulated or dataset-compressed (deflated) transfer syntax (no
stable byte offsets into native pixels), or no top-level, defined-length PixelData.
read_until is ignored. Elements after PixelData (trailing padding, digital signatures)
are not read.
Sourcepub fn open_file_deferring(
self,
path: impl AsRef<Path>,
defer: &dyn Fn(&DataElementHeader) -> bool,
defer_pixel_sequences: bool,
) -> Result<Option<(DefaultDicomObject, DeferredValues)>, ReadError>
pub fn open_file_deferring( self, path: impl AsRef<Path>, defer: &dyn Fn(&DataElementHeader) -> bool, defer_pixel_sequences: bool, ) -> Result<Option<(DefaultDicomObject, DeferredValues)>, ReadError>
Read path in full except for the large values defer picks out - plus, when
defer_pixel_sequences is set, encapsulated pixel data - which are skipped by seeking
past them and returned as file locations in [DeferredValues] instead (e.g. to emit as
DICOM JSON BulkDataURIs without ever reading them). Deferred elements stay in the object
with an empty placeholder value; see [DeferredValues].
Returns Ok(None) when byte offsets in the file can’t be relied on, so the caller should
read in full instead: a dataset-compressed (deflated) transfer syntax, a data set that
isn’t a seekable Part 10 file, or a deferred range that runs past the end of the file
(truncation - a full read reports that properly). read_until is ignored.
Sourcepub fn from_reader_deferring<R: Read + Seek>(
self,
source: R,
source_len: Option<u64>,
defer: &dyn Fn(&DataElementHeader) -> bool,
defer_pixel_sequences: bool,
stop_at_pixel_data: bool,
) -> Result<Option<(DefaultDicomObject, DeferredValues)>, ReadError>
pub fn from_reader_deferring<R: Read + Seek>( self, source: R, source_len: Option<u64>, defer: &dyn Fn(&DataElementHeader) -> bool, defer_pixel_sequences: bool, stop_at_pixel_data: bool, ) -> Result<Option<(DefaultDicomObject, DeferredValues)>, ReadError>
Self::open_file_deferring over any seekable Part 10 source, positioned at its
preamble: a byte slice in a Cursor, or a forward-only stream behind an adapter that
implements forward Seek by reading and discarding (the reader only ever seeks forward,
relative to its current position). source_len, when known, is checked against the
deferred ranges as the file length is; with None that check is the caller’s.
With stop_at_pixel_data, nothing past the top-level PixelData header is read: PixelData
is recorded as deferred where its value starts (length
crate::DeferredValueLocation::UNDEFINED_LENGTH when encapsulated) and later elements
are left out, as dcm4che’s readDatasetUntilPixelData does.
Sourcepub fn open_file_deferring_pixel_data(
self,
path: impl AsRef<Path>,
) -> Result<Option<(DefaultDicomObject, DeferredPixelData, File)>, ReadError>
pub fn open_file_deferring_pixel_data( self, path: impl AsRef<Path>, ) -> Result<Option<(DefaultDicomObject, DeferredPixelData, File)>, ReadError>
Read path in full except for top-level (7FE0,0010) PixelData, which is left on disk
and described by crate::DeferredPixelData (native offset/length, or encapsulated
Basic Offset Table plus per-fragment offsets/lengths). Every other element - including
nested IconImageSequence pixels and trailing elements after PixelData - is loaded
normally.
Returns Ok(None) when the file cannot be read this way (dataset-compressed / deflated
transfer syntax, or a deferred range running past EOF) so the caller can fall back to a
full read.
Trait Implementations§
Source§impl Clone for OpenFileOptions
impl Clone for OpenFileOptions
Source§impl Debug for OpenFileOptions
impl Debug for OpenFileOptions
Auto Trait Implementations§
impl Forget for OpenFileOptions
impl Freeze for OpenFileOptions
impl Move for OpenFileOptions
impl RefUnwindSafe for OpenFileOptions
impl Send for OpenFileOptions
impl Sync for OpenFileOptions
impl Unpin for OpenFileOptions
impl UnsafeUnpin for OpenFileOptions
impl UnwindSafe for OpenFileOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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