fn build_object<'s, S: 's, P>(
        dataset: &mut DataSetReader<S, P, D>,
        dict: D,
        in_item: bool,
        len: Length,
    ) -> Result<Self>
    where
        S: Read,
        P: Parse<dyn Read + 's>,
    {
        let mut entries: BTreeMap<Tag, InMemElement<D>> = BTreeMap::new();
        // perform a structured parsing of incoming tokens
        while let Some(token) = dataset.next() {
            let elem = match token? {
                DataToken::ElementHeader(header) => {
                    // fetch respective value, place it in the entries
                    let next_token = dataset.next().ok_or_else(|| Error::MissingElementValue)?;
                    match next_token? {
                        DataToken::PrimitiveValue(v) => {
                            InMemElement::new(header.tag, header.vr, Value::Primitive(v))
                        }
                        token => {
                            return Err(DataSetSyntaxError::UnexpectedToken(token).into());
                        }
                    }
                }
                DataToken::SequenceStart { tag, len } => {
                    // delegate sequence building to another function
                    let items = Self::build_sequence(tag, len, &mut *dataset, &dict)?;
                    DataElement::new(tag, VR::SQ, Value::Sequence { items, size: len })
                }
                DataToken::ItemEnd if in_item => {
                    // end of item, leave now
                    return Ok(InMemDicomObject { entries, dict, len });
                }
                token => return Err(DataSetSyntaxError::UnexpectedToken(token).into()),
            };
            entries.insert(elem.tag(), elem);
        }

        Ok(InMemDicomObject { entries, dict, len })
    }
/// Build an object by consuming a data set parser.
Build an object by consuming a data set parser.
Build an object by consuming a data set parser .
fn build_object<'s, S: 's, P>(
        dataset: &mut DataSetReader<S, P, D>,
        dict: D,
        in_item: bool,
        len: Length,
    ) -> Result<Self>
    where
        S: Read,
        P: Parse<dyn Read + 's>,
    {
        let mut entries: BTreeMap<Tag, InMemElement<D>> = BTreeMap::new();
        // perform a structured parsing of incoming tokens
        while let Some(token) = dataset.next() {
            let elem = match token? {
                DataToken::ElementHeader(header) => {
                    // fetch respective value, place it in the entries
                    let next_token = dataset.next().ok_or_else(|| Error::MissingElementValue)?;
                    match next_token? {
                        DataToken::PrimitiveValue(v) => {
                            InMemElement::new(header.tag, header.vr, Value::Primitive(v))
                        }
                        token => {
                            return Err(DataSetSyntaxError::UnexpectedToken(token).into());
                        }
                    }
                }
                DataToken::SequenceStart { tag, len } => {
                    // delegate sequence building to another function
                    let items = Self::build_sequence(tag, len, &mut *dataset, &dict)?;
                    DataElement::new(tag, VR::SQ, Value::Sequence { items, size: len })
                }
                DataToken::ItemEnd if in_item => {
                    // end of item, leave now
                    return Ok(InMemDicomObject { entries, dict, len });
                }
                token => return Err(DataSetSyntaxError::UnexpectedToken(token).into()),
            };
            entries.insert(elem.tag(), elem);
        }
        Ok(InMemDicomObject { entries, dict, len })
    }
fn build_object < ' s , S : ' s , P > ( dataset : & mut DataSetReader < S , P , D > , dict : D , in_item : bool , len : Length , ) -> Result < Self > where S : Read , P : Parse < dyn Read + ' s > , { let mut entries : BTreeMap < Tag , InMemElement < D > > = BTreeMap :: new ( ) ; // perform a structured parsing of incoming tokens while let Some ( token ) = dataset . next ( ) { let elem = match token ? { DataToken :: ElementHeader ( header ) => { // fetch respective value, place it in the entries let next_token = dataset . next ( ) . ok_or_else ( | | Error :: MissingElementValue ) ? ; match next_token ? { DataToken :: PrimitiveValue ( v ) => { InMemElement :: new ( header . tag , header . vr , Value :: Primitive ( v ) ) } token => { return Err ( DataSetSyntaxError :: UnexpectedToken ( token ) . into ( ) ) ; } } } DataToken :: SequenceStart { tag , len } => { // delegate sequence building to another function let items = Self :: build_sequence ( tag , len , & mut * dataset , & dict ) ? ; DataElement :: new ( tag , VR :: SQ , Value :: Sequence { items , size : len } ) } DataToken :: ItemEnd if in_item => { // end of item, leave now return Ok ( InMemDicomObject { entries , dict , len } ) ; } token => return Err ( DataSetSyntaxError :: UnexpectedToken ( token ) . into ( ) ) , } ; entries . insert ( elem . tag ( ) , elem ) ; } Ok ( InMemDicomObject { entries , dict , len } ) }
Build an object by consuming a data set parser.
Build an object by consuming a data set parser .
dataset
&mut DataSetReader<S, P, D>
dict
D
in_item
bool
len
Length
dataset
&mut DataSetReader<S, P, D>
dict
D
in_item
bool
len
Length