Trait mhash::WriteMultiHash
[−]
[src]
pub trait WriteMultiHash { fn write_multihash(&mut self, multihash: &MultiHash) -> Result<()>; }
A trait to allow writing a MultiHash
to an object.
This is primarily intended to provide support for the io::Write
trait,
allowing writing a MultiHash
to a stream without having to allocate space
to store the bytes.
Required Methods
fn write_multihash(&mut self, multihash: &MultiHash) -> Result<()>
Write the given MultiHash
to this object.
Errors
Any errors encountered when writing to the underlying io::Write
stream will be propagated out, if that happens an undefined amount of
the MultiHash
will have already been written to the stream.
Examples
use mhash::{ MultiHash, MultiHashVariant, WriteMultiHash }; let mut buffer = vec![]; let multihash = MultiHash::new( MultiHashVariant::Sha1, &[0xde, 0xad, 0xbe, 0xef]).unwrap(); buffer.write_multihash(&multihash).unwrap(); assert_eq!(buffer, [0x11, 0x04, 0xde, 0xad, 0xbe, 0xef]);
Implementors
impl<W> WriteMultiHash for W where
W: Write,