[][src]Trait parity_scale_codec::EncodeAppend

pub trait EncodeAppend {
    type Item: Encode;
    fn append<'a, I: IntoIterator<Item = &'a Self::Item>>(
        self_encoded: Vec<u8>,
        iter: I
    ) -> Result<Vec<u8>, Error>
    where
        Self::Item: 'a,
        I::IntoIter: ExactSizeIterator
;
fn append_or_new<EncodeLikeItem, I>(
        self_encoded: Vec<u8>,
        iter: I
    ) -> Result<Vec<u8>, Error>
    where
        I: IntoIterator<Item = EncodeLikeItem>,
        EncodeLikeItem: EncodeLike<Self::Item>,
        I::IntoIter: ExactSizeIterator
; }

Trait that allows to append items to an encoded representation without decoding all previous added items.

Associated Types

type Item: Encode

The item that will be appended.

Loading content...

Required methods

fn append<'a, I: IntoIterator<Item = &'a Self::Item>>(
    self_encoded: Vec<u8>,
    iter: I
) -> Result<Vec<u8>, Error> where
    Self::Item: 'a,
    I::IntoIter: ExactSizeIterator

👎 Deprecated:

Consider using append_or_new instead

Append all items in iter to the given self_encoded representation or if self_encoded value is empty then insert the given input data.

fn append_or_new<EncodeLikeItem, I>(
    self_encoded: Vec<u8>,
    iter: I
) -> Result<Vec<u8>, Error> where
    I: IntoIterator<Item = EncodeLikeItem>,
    EncodeLikeItem: EncodeLike<Self::Item>,
    I::IntoIter: ExactSizeIterator

Append all items in iter to the given self_encoded representation or if self_encoded value is empty, iter is encoded to the Self representation.

Example


// Some encoded data
let data = Vec::new();

let item = 8u32;
let encoded = <Vec<u32> as EncodeAppend>::append(data, std::iter::once(&item)).expect("Adds new element");

// Add multiple element
<Vec<u32> as EncodeAppend>::append(encoded, &[700u32, 800u32, 10u32]).expect("Adds new elements");
Loading content...

Implementations on Foreign Types

impl<T: Encode> EncodeAppend for Vec<T>[src]

type Item = T

impl<T: Encode> EncodeAppend for VecDeque<T>[src]

type Item = T

Loading content...

Implementors

Loading content...