Struct rlp::RlpStream [] [src]

pub struct RlpStream { /* fields omitted */ }

Appendable rlp encoder.

Methods

impl RlpStream
[src]

[src]

Initializes instance of empty Stream.

[src]

Initializes the Stream as a list.

[src]

Appends value to the end of stream, chainable.

extern crate rlp;
use rlp::*;

fn main () {
    let mut stream = RlpStream::new_list(2);
    stream.append(&"cat").append(&"dog");
    let out = stream.out();
    assert_eq!(out, vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']);
}

[src]

Appends list of values to the end of stream, chainable.

[src]

Appends value to the end of stream, but do not count it as an appended item. It's useful for wrapper types

[src]

Declare appending the list of given size, chainable.

extern crate rlp;
use rlp::*;

fn main () {
    let mut stream = RlpStream::new_list(2);
    stream.begin_list(2).append(&"cat").append(&"dog");
    stream.append(&"");
    let out = stream.out();
    assert_eq!(out, vec![0xca, 0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g', 0x80]);
}

[src]

Declare appending the list of unknown size, chainable.

[src]

Apends null to the end of stream, chainable.

extern crate rlp;
use rlp::*;

fn main () {
    let mut stream = RlpStream::new_list(2);
    stream.append_empty_data().append_empty_data();
    let out = stream.out();
    assert_eq!(out, vec![0xc2, 0x80, 0x80]);
}

[src]

Appends raw (pre-serialised) RLP data. Use with caution. Chainable.

[src]

Appends raw (pre-serialised) RLP data. Checks for size oveflow.

[src]

Calculate total RLP size for appended payload.

[src]

Returns current RLP size in bytes for the data pushed into the list.

[src]

Clear the output stream so far.

extern crate rlp;
use rlp::*;

fn main () {
    let mut stream = RlpStream::new_list(3);
    stream.append(&"cat");
    stream.clear();
    stream.append(&"dog");
    let out = stream.out();
    assert_eq!(out, vec![0x83, b'd', b'o', b'g']);
}

[src]

Returns true if stream doesnt expect any more items.

extern crate rlp;
use rlp::*;

fn main () {
    let mut stream = RlpStream::new_list(2);
    stream.append(&"cat");
    assert_eq!(stream.is_finished(), false);
    stream.append(&"dog");
    assert_eq!(stream.is_finished(), true);
    let out = stream.out();
    assert_eq!(out, vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']);
}

[src]

Get raw encoded bytes

[src]

Streams out encoded bytes.

panic! if stream is not finished.

[src]

[src]

Drain the object and return the underlying ElasticArray.

[src]

Finalize current ubnbound list. Panics if no unbounded list has been opened.

Trait Implementations

impl Default for RlpStream
[src]

[src]

Returns the "default value" for a type. Read more