fn try_from(value: &[u8]) -> std::result::Result<Self, Self::Error> {
        let dict = match sfv::Parser::parse_dictionary(value) {
            Ok(v) => v,

            Err(_) => return Err(Error::Done),
        };

        let urgency = match dict.get("u") {
            // If there is a u parameter, try to read it as an Item of type
            // Integer. If the value out of the spec's allowed range
            // (0 through 7), that's an error so set it to the upper
            // bound (lowest priority) to avoid interference with
            // other streams.
            Some(sfv::ListEntry::Item(item)) => match item.bare_item.as_int() {
                Some(v) => {
                    if !(PRIORITY_URGENCY_LOWER_BOUND as i64..=
                        PRIORITY_URGENCY_UPPER_BOUND as i64)
                        .contains(&v)
                    {
                        PRIORITY_URGENCY_UPPER_BOUND
                    } else {
                        v as u8
                    }
                },

                None => return Err(Error::Done),
            },

            Some(sfv::ListEntry::InnerList(_)) => return Err(Error::Done),

            // Omitted so use default value.
            None => PRIORITY_URGENCY_DEFAULT,
        };

        let incremental = match dict.get("i") {
            Some(sfv::ListEntry::Item(item)) =>
                item.bare_item.as_bool().ok_or(Error::Done)?,

            // Omitted so use default value.
            _ => false,
        };

        Ok(Priority::new(urgency as u8, incremental))
    }
/// Try to parse an Extensible Priority field value.
///
/// The field value is expected to be a Structured Fields Dictionary; see
/// [Extensible Priorities].
///
/// If the `u` or `i` fields are contained with correct types, a constructed
/// Priority object is returned. Note that urgency values outside of valid
/// range (0 through 7) are clamped to 7.
///
/// If the `u` or `i` fields are contained with the wrong types,
/// Error::Done is returned.
///
/// Omitted parameters will yield default values.
///
/// [Extensible Priorities]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-priority-12#section-4.
Try to parse an Extensible Priority field value.
The field value is expected to be a Structured Fields Dictionary; see
[Extensible Priorities].

If the `u` or `i` fields are contained with correct types, a constructed
Priority object is returned. Note that urgency values outside of valid
range (0 through 7) are clamped to 7.

If the `u` or `i` fields are contained with the wrong types,
Error::Done is returned.

Omitted parameters will yield default values.


Try to parse an Extensible Priority field value . The field value is expected to be a Structured Fields Dictionary ; see [ Extensible Priorities ] . If the ` u ` or ` i ` fields are contained with correct types a constructed Priority object is returned . Note that urgency values outside of valid range ( 0 through 7 ) are clamped to 7 . If the ` u ` or ` i ` fields are contained with the wrong types Error :: Done is returned . Omitted parameters will yield default values .
fn try_from(value: &[u8]) -> std::result::Result<Self, Self::Error> {
        let dict = match sfv::Parser::parse_dictionary(value) {
            Ok(v) => v,
            Err(_) => return Err(Error::Done),
        };
        let urgency = match dict.get("u") {
            // If there is a u parameter, try to read it as an Item of type
            // Integer. If the value out of the spec's allowed range
            // (0 through 7), that's an error so set it to the upper
            // bound (lowest priority) to avoid interference with
            // other streams.
            Some(sfv::ListEntry::Item(item)) => match item.bare_item.as_int() {
                Some(v) => {
                    if !(PRIORITY_URGENCY_LOWER_BOUND as i64..=
                        PRIORITY_URGENCY_UPPER_BOUND as i64)
                        .contains(&v)
                    {
                        PRIORITY_URGENCY_UPPER_BOUND
                    } else {
                        v as u8
                    }
                },
                None => return Err(Error::Done),
            },
            Some(sfv::ListEntry::InnerList(_)) => return Err(Error::Done),
            // Omitted so use default value.
            None => PRIORITY_URGENCY_DEFAULT,
        };
        let incremental = match dict.get("i") {
            Some(sfv::ListEntry::Item(item)) =>
                item.bare_item.as_bool().ok_or(Error::Done)?,
            // Omitted so use default value.
            _ => false,
        };
        Ok(Priority::new(urgency as u8, incremental))
    }
fn try_from ( value : & [ u8 ] ) -> std :: result :: Result < Self , Self :: Error > { let dict = match sfv :: Parser :: parse_dictionary ( value ) { Ok ( v ) => v , Err ( _ ) => return Err ( Error :: Done ) , } ; let urgency = match dict . get ( " " ) { // If there is a u parameter, try to read it as an Item of type // Integer. If the value out of the spec's allowed range // (0 through 7), that's an error so set it to the upper // bound (lowest priority) to avoid interference with // other streams. Some ( sfv :: ListEntry :: Item ( item ) ) => match item . bare_item . as_int ( ) { Some ( v ) => { if ! ( PRIORITY_URGENCY_LOWER_BOUND as i64 ..= PRIORITY_URGENCY_UPPER_BOUND as i64 ) . contains ( & v ) { PRIORITY_URGENCY_UPPER_BOUND } else { v as u8 } } , None => return Err ( Error :: Done ) , } , Some ( sfv :: ListEntry :: InnerList ( _ ) ) => return Err ( Error :: Done ) , // Omitted so use default value. None => PRIORITY_URGENCY_DEFAULT , } ; let incremental = match dict . get ( " " ) { Some ( sfv :: ListEntry :: Item ( item ) ) => item . bare_item . as_bool ( ) . ok_or ( Error :: Done ) ? , // Omitted so use default value. _ => false , } ; Ok ( Priority :: new ( urgency as u8 , incremental ) ) }
Try to parse an Extensible Priority field value.
Try to parse an Extensible Priority field value .
value
&[u8]
value
&[u8]