The ToBytes
and IterBytes
traits
Cb
IterBytes
ToBytes
- A trait for converting a value to a list of bytes.of IterBytes for bool
of IterBytes for u8
of IterBytes for u16
of IterBytes for u32
of IterBytes for u64
of IterBytes for i8
of IterBytes for i16
of IterBytes for i32
of IterBytes for i64
of IterBytes for char
of IterBytes for uint
of IterBytes for int
of IterBytes for float
of IterBytes for f32
of IterBytes for f64
of IterBytes for &'self [A] where <'self, A: IterBytes>
of IterBytes for (A, B) where <A: IterBytes, B: IterBytes>
of IterBytes for (A, B, C) where <A: IterBytes, B: IterBytes, C: IterBytes>
of IterBytes for ~[A] where <A: IterBytes>
of IterBytes for @[A] where <A: IterBytes>
of IterBytes for &'self str where <'self>
of IterBytes for ~str
of IterBytes for @str
of IterBytes for Option<A> where <A: IterBytes>
of IterBytes for &'self A where <'self, A: IterBytes>
of IterBytes for @A where <A: IterBytes>
of IterBytes for ~A where <A: IterBytes>
of IterBytes for *const A where <A>
of ToBytes for A where <A: IterBytes>
Cb
type Cb<'self> = &'self fn(buf: &[u8]) -> bool
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.
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.
ToBytes
A trait for converting a value to a list of bytes.
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
IterBytes
for bool
iter_bytes
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool
IterBytes
for u8
iter_bytes
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool
IterBytes
for u16
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for u32
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for u64
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for i8
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for i16
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for i32
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for i64
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for char
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for uint
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for int
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for float
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for f32
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for f64
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for &'self [A]
where <'self, A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for (A, B)
where <A: IterBytes, B: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for (A, B, C)
where <A: IterBytes, B: IterBytes, C: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for ~[A]
where <A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for @[A]
where <A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for &'self str
where <'self>
iter_bytes
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool
IterBytes
for ~str
iter_bytes
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool
IterBytes
for @str
iter_bytes
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool
IterBytes
for Option<A>
where <A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for &'self A
where <'self, A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for @A
where <A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for ~A
where <A: IterBytes>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
IterBytes
for *const A
where <A>
iter_bytes
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool
ToBytes
for A
where <A: IterBytes>
to_bytes
fn to_bytes(&self, lsb0: bool) -> ~[u8]