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
impl DefaultDicomObject
Sourcepub fn new_empty_with_meta(meta: FileMetaTable) -> Self
pub fn new_empty_with_meta(meta: FileMetaTable) -> Self
Construct a new, empty object already carrying the given meta table.
Sourcepub fn put_str(&mut self, tag: Tag, vr: VR, value: impl Into<String>)
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.
Sourcepub fn open_file(path: impl AsRef<Path>) -> Result<Self, ReadError>
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.
Sourcepub fn from_reader(source: impl Read) -> Result<Self, ReadError>
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.
Sourcepub fn write_to_file(&self, path: impl AsRef<Path>) -> Result<(), WriteError>
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.
Sourcepub fn write_all(&self, to: impl Write) -> Result<(), WriteError>
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.
Sourcepub 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>,
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>§
Sourcepub fn get(&self, tag: Tag) -> Option<&InMemElement>
pub fn get(&self, tag: Tag) -> Option<&InMemElement>
Look up an element by tag. Returns None if absent.
Sourcepub fn get_mut(&mut self, tag: Tag) -> Option<&mut InMemElement>
pub fn get_mut(&mut self, tag: Tag) -> Option<&mut InMemElement>
Look up a mutable element by tag. Returns None if absent.
Sourcepub fn element(&self, tag: Tag) -> Result<&InMemElement, MissingElementError>
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.
Sourcepub fn put_str(&mut self, tag: Tag, vr: VR, value: impl Into<String>)
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.
Sourcepub fn put(&mut self, element: InMemElement)
pub fn put(&mut self, element: InMemElement)
Insert or replace an element, keeping the element list in tag order.
Sourcepub fn remove_element(&mut self, tag: Tag) -> bool
pub fn remove_element(&mut self, tag: Tag) -> bool
Remove an element by tag. Returns whether an element was actually present.
Sourcepub fn iter(&self) -> impl Iterator<Item = &InMemElement>
pub fn iter(&self) -> impl Iterator<Item = &InMemElement>
Iterate over all elements, in tag order.
pub fn is_empty(&self) -> bool
Sourcepub fn apply(&mut self, op: AttributeOp) -> Result<(), ApplyOpError>
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.
Sourcepub fn specific_character_set(&self) -> SpecificCharacterSet
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.
Sourcepub fn write_dataset_with_ts<'w, W: Write + 'w>(
&self,
to: W,
ts: &TransferSyntax,
) -> Result<(), WriteError>
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.
Sourcepub 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>,
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).
Sourcepub fn write_elements_to_writer<'w, W: Write>(
&self,
writer: &mut DataSetWriter<W, DynEncoder<'w, W>>,
) -> Result<(), WriteError>
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).