Skip to main content

OpenFileOptions

Struct OpenFileOptions 

Source
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

Source

pub fn new() -> Self

Source

pub fn read_preamble(self, mode: ReadPreamble) -> Self

Source

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.

Source

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.

Source

pub fn open_file( self, path: impl AsRef<Path>, ) -> Result<DefaultDicomObject, ReadError>

Source

pub fn from_reader( self, source: impl Read, ) -> Result<DefaultDicomObject, ReadError>

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OpenFileOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OpenFileOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more