pub struct Array { /* private fields */ }Expand description
Content of an array, CBOR major type 4.
An array holds an ordered sequence of data items and remembers whether it
was encoded with a definite length or with the indefinite length form
terminated by a break. The items themselves are reached through
items and its mutable and owning counterparts.
§Example
use cbor_next::{Array, DataItem};
let mut content = Array::from_items([1, 2]);
content.extend([3]);
assert_eq!(content.items().len(), 3);
assert_eq!(content.items()[2], DataItem::from(3));
assert!(!content.is_indefinite());Implementations§
Source§impl Array
impl Array
Sourcepub fn from_items<I, T>(items: I) -> Self
pub fn from_items<I, T>(items: I) -> Self
Create a definite length array from a sequence of items.
Sourcepub fn with_indefinite(self, indefinite: bool) -> Self
pub fn with_indefinite(self, indefinite: bool) -> Self
Return the same content with the definite or indefinite encoding selected.
§Example
use cbor_next::Array;
let content = Array::from_items([1, 2]).with_indefinite(true);
assert!(content.is_indefinite());Sourcepub fn set_indefinite(&mut self, indefinite: bool)
pub fn set_indefinite(&mut self, indefinite: bool)
Select the definite or indefinite encoding in place.
Sourcepub fn is_indefinite(&self) -> bool
pub fn is_indefinite(&self) -> bool
Whether the array uses the indefinite length encoding.
Sourcepub fn into_items(self) -> Vec<DataItem>
pub fn into_items(self) -> Vec<DataItem>
Take ownership of the items of the array.
Trait Implementations§
impl Eq for Array
Source§impl<T> Extend<T> for Array
impl<T> Extend<T> for Array
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T> FromIterator<T> for Array
impl<T> FromIterator<T> for Array
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl StructuralPartialEq for Array
Auto Trait Implementations§
impl Freeze for Array
impl RefUnwindSafe for Array
impl Send for Array
impl Sync for Array
impl Unpin for Array
impl UnsafeUnpin for Array
impl UnwindSafe for Array
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.