pub struct Sequence<'a> { /* private fields */ }Expand description
A CBOR Sequence.
Typical actions on this are the same as on StandaloneItem, but it can process multiple CBOR
items in a row, and thus offers interaction with all those items:
let from_edn = Sequence::parse("
1
2
3
").unwrap();
assert_eq!(from_edn.items().count(), 3);Implementations§
Source§impl<'a> Sequence<'a>
impl<'a> Sequence<'a>
Sourcepub fn parse(s: &'a str) -> Result<Self, ParseError>
pub fn parse(s: &'a str) -> Result<Self, ParseError>
Ingests CBOR Diagnostic Notation (EDN) representing a CBOR sequence
Note that this will only return syntactic errors. Content errors that make it impossible to produce this as CBOR, such as non-matching encoding indicators or unknown application oriented literals, are not reported.
pub fn from_cbor(cbor: &[u8]) -> Result<Self, CborError>
Sourcepub fn from_cbor_possibly_incomplete(cbor: &[u8]) -> Result<Self, CborError>
pub fn from_cbor_possibly_incomplete(cbor: &[u8]) -> Result<Self, CborError>
Parses a CBOR sequence, allowing incomplete items.
If at the end of the data there is an incomplete CBOR item, rather than producing an error, this produces ellipses wherever there is incomplete data.
let from_cbor = Sequence::from_cbor_possibly_incomplete(
&[0x82, 0x65, 0x61, 0x62, 0x63]
).unwrap();
assert_eq!(from_cbor.serialize(), r#"["abc" + ..., ...], ..."#);Sourcepub fn to_cbor(&self) -> Result<Vec<u8>, InconsistentEdn>
pub fn to_cbor(&self) -> Result<Vec<u8>, InconsistentEdn>
Encode into a binary CBOR representation
Sourcepub fn items_mut(&mut self) -> impl Iterator<Item = &mut Item<'a>>
pub fn items_mut(&mut self) -> impl Iterator<Item = &mut Item<'a>>
Mutably access the items of the sequence
pub fn get_items_mut(&mut self) -> impl Iterator<Item = &mut Item<'a>>
renamed to items_mut()
Sourcepub fn discard_encoding_indicators(&mut self)
pub fn discard_encoding_indicators(&mut self)
Removes any encoding indicators present in the sequence.
This does not affect space or comments; in particular, an item containing only the necessary space may be left with extraneous (but harmless) space that was previously needed to set an encoding indicator apart from a value.
Sourcepub fn cloned<'any>(&self) -> Sequence<'any>
pub fn cloned<'any>(&self) -> Sequence<'any>
Clone the item, turning any Cow::Borrowed into owned versions, which can then satisfy
any lifetime.