Skip to main content

DefaultDicomObject

Type Alias DefaultDicomObject 

Source
pub type DefaultDicomObject = FileDicomObject<InMemDicomObject>;
Expand description

The default, in-memory DICOM file object type - a FileMetaTable plus an InMemDicomObject.

Aliased Type§

pub struct DefaultDicomObject { /* private fields */ }

Implementations§

Source§

impl DefaultDicomObject

Source

pub fn new_empty_with_meta(meta: FileMetaTable) -> Self

Construct a new, empty object already carrying the given meta table.

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.

Source

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

Read a Part 10 file (128-byte preamble + “DICM” magic + meta group + data set) from path.

Source

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

Read a Part 10 object (128-byte preamble + “DICM” magic + meta group + data set) from any Read source.

Source

pub fn write_to_file(&self, path: impl AsRef<Path>) -> Result<(), WriteError>

Write this object as a full Part 10 file (preamble + “DICM” magic + meta group + data set) to path.

Source

pub fn write_all(&self, to: impl Write) -> Result<(), WriteError>

Write this object as a full Part 10 stream (preamble + “DICM” magic + meta group + data set) to any Write sink.

Source

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

Write this object as a full Part 10 stream, delegating (7FE0,0010) PixelData to write_pixel_data at its exact tag-order position. The second argument passed to the closure is the byte offset within to where the data set starts (right after the Part 10 preamble + File Meta Information).

Methods from Deref<Target = InMemDicomObject>§

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 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).

Trait Implementations§

Source§

impl ApplyOp for DefaultDicomObject

Source§

type Err = ApplyOpError

The operation error type
Source§

fn apply(&mut self, op: AttributeOp) -> Result<(), Self::Err>

Apply the given attribute operation on the receiving object. Read more
Source§

impl Deref for DefaultDicomObject

Source§

type Target = InMemDicomObject

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for DefaultDicomObject

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.