pub struct Element { /* private fields */ }Expand description
A unit of CBOR-encoded data
Each Element contains:
- A major number, indicating the type of data.
- An “additional information” field.
- A Zero-to-eight byte immediate value (containing a numeric value or length).
- An optional sequence of payload bytes.
See RFC 7049 for details.
Some CborType values will require multiple Elements to encode.
Implementations§
Source§impl Element
impl Element
Sourcepub fn new(major: Major, adn_info: AdnInfo, imm: ImmediateValue) -> Element
pub fn new(major: Major, adn_info: AdnInfo, imm: ImmediateValue) -> Element
Create a new Element, with no payload buffer.
Sourcepub fn simple(major: Major, adn_info: AdnInfo) -> Element
pub fn simple(major: Major, adn_info: AdnInfo) -> Element
Create a new Element, with no payload buffer or immediate data.
Sourcepub fn get_length(&self) -> Result<usize, DecodeError>
pub fn get_length(&self) -> Result<usize, DecodeError>
Extract a length value from the Element.
In many elements, the adn_info and imm fields encode a length parameter.
This function attempts to extract that value.
If the adn_info is not a value between 0 and 27, it will return an error.
Trait Implementations§
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more