Replies: 1 comment
-
Sorry, this question must have slipped. Yes, the errors need to be handled at each access level. Note that your code also panics if the DICOM object is malformed and the value behind a sequence tag is something other than a sequence. By using Snafu, both results and options can be handled appropriately. Here is a function that does better safeguarding (consider later on migrating from use snafu::{ResultExt, OptionExt};
fn get_item<'a, D>(
obj: &'a InMemDicomObject<D>,
tag: Tag,
name: &'static str,
) -> Result<&'a InMemDicomObject<D>, snafu::Whatever>
where
D: Clone + DataDictionary,
{
Ok(obj
.element(tag)
.whatever_context("missing attribute")?
.items()
.whatever_context("not a sequence")?
.get(0)
.context("item index in sequence out of range")?)
} However, with the attribute selector API around the corner (#326 #383), we could also have a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to access some nested tags in a dicom in an efficient way. Such tags could also be not present.
So far I have a basic implementation that does the job, but as you see it has a lot of
.unwrap()
calls. How to make it more efficient and handle theOption
results all at once?Beta Was this translation helpful? Give feedback.
All reactions