pub trait KeyEncode {
// Required method
fn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>;
// Provided methods
fn encode(&self) -> Result<Vec<u8>, Error> { ... }
fn encode_owned(self) -> Result<Vec<u8>, Error>
where Self: Sized { ... }
fn encode_owned_into(self, buffer: &mut Vec<u8>) -> Result<(), Error>
where Self: Sized { ... }
}
Expand description
A trait for types which can be encoded as a kv-store key.
Required Methods§
Sourcefn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>
fn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>
Push the bytes this key would encode into the buffer.
Implementation can make no assumption about the contents of the buffer. The buffer should not be cleared and if there are bytes present in the buffer they should also be present when this function returns.