Skip to main content

InMemDicomObject

Struct InMemDicomObject 

Source
pub struct InMemDicomObject { /* private fields */ }
Expand description

An in-memory DICOM data set: a flat, tag-ordered list of elements, each of which may itself contain a nested list (for SQ values).

Implementations§

Source§

impl InMemDicomObject

Source

pub fn new_empty() -> Self

An empty object with no elements.

Source

pub fn from_element_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = InMemElement>,

Build an object directly from a list of elements, sorting them into tag order. Matches dicom_object::InMemDicomObject::from_element_iter.

Source

pub fn command_from_element_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = InMemElement>,

Build a DIMSE command data set from a list of elements. DIMSE command sets have the same shape as a regular data set (a flat list of primitive elements, always Implicit VR Little Endian on the wire per PS3.7) - this is an alias for Self::from_element_iter kept for call-site clarity in dimse.rs/scp.rs.

Source

pub fn get(&self, tag: Tag) -> Option<&InMemElement>

Look up an element by tag. Returns None if absent.

Source

pub fn get_mut(&mut self, tag: Tag) -> Option<&mut InMemElement>

Look up a mutable element by tag. Returns None if absent.

Source

pub fn element(&self, tag: Tag) -> Result<&InMemElement, MissingElementError>

Look up an element by tag, returning a Result (an Err with a descriptive message on absence) rather than Option - for call sites that want to ?-propagate a hard failure on a required element.

Source

pub fn put_str(&mut self, tag: Tag, vr: VR, value: impl Into<String>)

Insert or replace a text element by tag and VR, creating it if absent. A thin convenience wrapper around Self::put for CLI-style attribute edits (--set KEY=VALUE) and DIMSE command/identifier construction that only ever deal in string values.

Source

pub fn put(&mut self, element: InMemElement)

Insert or replace an element, keeping the element list in tag order.

Source

pub fn remove_element(&mut self, tag: Tag) -> bool

Remove an element by tag. Returns whether an element was actually present.

Source

pub fn iter(&self) -> impl Iterator<Item = &InMemElement>

Iterate over all elements, in tag order.

Source

pub fn len(&self) -> usize

The number of top-level elements in this object.

Source

pub fn is_empty(&self) -> bool

Source

pub fn apply(&mut self, op: AttributeOp) -> Result<(), ApplyOpError>

Apply an attribute mutation, as returned by a pixel data encoder after transcoding (e.g. a Photometric Interpretation or Planar Configuration adjustment required by the new transfer syntax).

§Errors

Returns ApplyOpError::UnsupportedSelector if op’s selector is not a single top-level tag. dcmnorm only ever applies single-step, top-level selectors today (confirmed by its own usage in io.rs - pixel data codec post-transcode attribute patches never target nested sequences), so a full attribute-selector-path walk isn’t implemented here - but a caller that does build one of those selectors should get a clear error, not have the operation silently do nothing.

Source

pub fn with_meta( self, builder: FileMetaTableBuilder, ) -> Result<FileDicomObject<Self>, WithMetaError>

Attach a [FileMetaTable] built from a crate::FileMetaTableBuilder, producing a crate::FileDicomObject.

Source

pub fn read_dataset_with_ts<'r, R: Read + 'r>( source: R, ts: &TransferSyntax, ) -> Result<Self, ReadError>

Read a bare data set (no Part 10 preamble/meta group) from source, using the given transfer syntax.

A dataset-level transfer syntax (currently just Deflated Explicit VR Little Endian) needs its own byte-stream transform applied before element decoding even starts - unlike a pixel-data codec, which only ever touches one element’s value. source is always boxed (not just when a codec applies) so this function has one concrete reader type to build a DataSetReader over regardless of transfer syntax.

Source

pub fn read_dataset_with_ts_options<'r, R: Read + 'r>( source: R, ts: &TransferSyntax, options: DataSetReaderOptions, ) -> Result<Self, ReadError>

Source

pub fn read_dataset_with_ts_cs<'r, R: Read + 'r>( source: R, ts: &TransferSyntax, cs: SpecificCharacterSet, ) -> Result<Self, ReadError>

Like Self::read_dataset_with_ts, seeded with an initial [SpecificCharacterSet] (e.g. when resuming a stream to read trailing elements after PixelData).

Source

pub fn specific_character_set(&self) -> SpecificCharacterSet

Returns the [SpecificCharacterSet] declared by (0008,0005) in this object, or the default character set if absent or unrecognized.

Source

pub fn write_dataset_with_ts<'w, W: Write + 'w>( &self, to: W, ts: &TransferSyntax, ) -> Result<(), WriteError>

Write this object as a bare data set (no Part 10 preamble/meta group) using the given transfer syntax. See Self::read_dataset_with_ts for why to is always boxed.

Source

pub fn write_dataset_with_ts_and_pixel_data<'w, W, E, F>( &self, to: W, ts: &TransferSyntax, write_pixel_data: F, ) -> Result<(), E>
where W: Write + 'w, E: From<WriteError>, F: FnOnce(&mut DataSetWriter<Box<dyn Write + 'w>, DynEncoder<'w, Box<dyn Write + 'w>>>) -> Result<(), E>,

Write this object as a bare data set, splitting top-level elements around (7FE0,0010) and invoking write_pixel_data at the exact tag-order position of PixelData (skipping any PixelData stored in self).

Source

pub fn write_elements_to_writer<'w, W: Write>( &self, writer: &mut DataSetWriter<W, DynEncoder<'w, W>>, ) -> Result<(), WriteError>

Write all elements in this object into an already-constructed DataSetWriter (e.g. trailing elements after streaming PixelData in a single-pass wire receiver).

Source

pub fn read_dataset_until_pixel_data<R: Read>( source: R, ts: &TransferSyntax, ) -> Result<(Self, PixelDataStreamStop), ReadError>

Read a bare data set from a forward-only stream up to (not including) top-level (7FE0,0010) PixelData’s value, returning all elements read so far and where the stream stopped. Because DataSetReader performs no read-ahead past the element header in hand, source is left positioned at byte 0 of PixelData’s value (or at the Basic Offset Table item header for encapsulated pixel data).

Does not apply dataset-level codecs (deflate) — callers must check ts.codec() first.

Trait Implementations§

Source§

impl Clone for InMemDicomObject

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 InMemDicomObject

Source§

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

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

impl Default for InMemDicomObject

Source§

fn default() -> Self

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

impl HasLength for InMemDicomObject

Source§

fn length(&self) -> Length

Retrieve the value data’s length as specified by the data element or item, in bytes. Read more
Source§

fn is_empty(&self) -> bool

Check whether the value is empty (0 length).
Source§

impl PartialEq for InMemDicomObject

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InMemDicomObject

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