Skip to content

Commit

Permalink
[object] fix rebase
Browse files Browse the repository at this point in the history
- remove duplicate value_at method
  • Loading branch information
Enet4 committed Apr 11, 2024
1 parent 35f9ca9 commit 6978b2c
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions object/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,82 +849,6 @@ where
}
}

/// Obtain the DICOM value by finding the element
/// that matches the given selector.
///
/// Returns an error if the respective element or any of its parents
/// cannot be found.
///
/// See the documentation of [`AttributeSelector`] for more information
/// on how to write attribute selectors.
///
/// See also [`entry_at`] to get the entry rather than the value.
///
/// # Example
///
/// ```no_run
/// # use dicom_core::prelude::*;
/// # use dicom_core::ops::AttributeSelector;
/// # use dicom_dictionary_std::tags;
/// # use dicom_object::InMemDicomObject;
/// # let obj: InMemDicomObject = unimplemented!();
/// let referenced_sop_instance_iod = obj.value_at(
/// (
/// tags::SHARED_FUNCTIONAL_GROUPS_SEQUENCE,
/// tags::REFERENCED_IMAGE_SEQUENCE,
/// tags::REFERENCED_SOP_INSTANCE_UID,
/// ))?
/// .to_str()?;
/// # Ok::<_, Box<dyn std::error::Error>>(())
/// ```
pub fn value_at(
&self,
selector: impl Into<AttributeSelector>,
) -> Result<&Value<InMemDicomObject<D>, InMemFragment>, AtAccessError> {
let selector = selector.into();

let mut obj = self;
for (i, step) in selector.iter().enumerate() {
match step {
// reached the leaf
AttributeSelectorStep::Tag(tag) => {
return obj.get(*tag).map(|e| e.value()).with_context(|| {
MissingLeafElementSnafu {
selector: selector.clone(),
}
})
}
// navigate further down
AttributeSelectorStep::Nested { tag, item } => {
let e = obj
.entries
.get(tag)
.with_context(|| crate::MissingSequenceSnafu {
selector: selector.clone(),
step_index: i as u32,
})?;

// get items
let items = e.items().with_context(|| NotASequenceSnafu {
selector: selector.clone(),
step_index: i as u32,
})?;

// if item.length == i and action is a constructive action, append new item
obj =
items
.get(*item as usize)
.with_context(|| crate::MissingSequenceSnafu {
selector: selector.clone(),
step_index: i as u32,
})?;
}
}
}

unreachable!()
}

/// Obtain a temporary mutable reference to a DICOM value by AttributeSelector,
/// so that mutations can be applied within.
///
Expand Down

0 comments on commit 6978b2c

Please sign in to comment.