The ToBytes and IterBytes traits

Type Cb

type Cb<'self> = &'self fn(buf: &[u8]) -> bool

Trait IterBytes

A trait to implement in order to make a type hashable; This works in combination with the trait Hash::Hash, and may in the future be merged with that trait or otherwise modified when default methods and trait inheritence are completed.

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Call the provided callback f one or more times with byte-slices that should be used when computing a hash value or otherwise "flattening" the structure into a sequence of bytes. The lsb0 parameter conveys whether the caller is asking for little-endian bytes (true) or big-endian (false); this should only be relevant in implementations that represent a single multi-byte datum such as a 32 bit integer or 64 bit floating-point value. It can be safely ignored for larger structured types as they are usually processed left-to-right in declaration order, regardless of underlying memory endianness.

Trait ToBytes

A trait for converting a value to a list of bytes.

Method to_bytes

fn to_bytes(&self, lsb0: bool) -> ~[u8]

Converts the current value to a list of bytes. This is equivalent to invoking iter_bytes on a type and collecting all yielded values in an array

Implementation of IterBytes for bool

Method iter_bytes

fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for u8

Method iter_bytes

fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for u16

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for u32

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for u64

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for i8

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for i16

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for i32

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for i64

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for char

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for uint

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for int

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for float

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for f32

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for f64

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for &'self [A] where <'self, A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for (A, B) where <A: IterBytes, B: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for (A, B, C) where <A: IterBytes, B: IterBytes, C: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for ~[A] where <A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for @[A] where <A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for &'self str where <'self>

Method iter_bytes

fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for ~str

Method iter_bytes

fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for @str

Method iter_bytes

fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for Option<A> where <A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for &'self A where <'self, A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for @A where <A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for ~A where <A: IterBytes>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of IterBytes for *const A where <A>

Method iter_bytes

fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool

Implementation of ToBytes for A where <A: IterBytes>

Method to_bytes

fn to_bytes(&self, lsb0: bool) -> ~[u8]