Trait KeyEncode

Source
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§

Source

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.

Provided Methods§

Source

fn encode(&self) -> Result<Vec<u8>, Error>

Source

fn encode_owned(self) -> Result<Vec<u8>, Error>
where Self: Sized,

Source

fn encode_owned_into(self, buffer: &mut Vec<u8>) -> Result<(), Error>
where Self: Sized,

Implementations on Foreign Types§

Source§

impl KeyEncode for &str

Source§

fn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>

Source§

impl KeyEncode for &[u8]

Source§

fn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>

Source§

impl KeyEncode for Vec<u8>

Source§

fn encode(&self) -> Result<Vec<u8>, Error>

Source§

fn encode_owned(self) -> Result<Vec<u8>, Error>

Source§

fn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>

Source§

fn encode_owned_into(self, buffer: &mut Vec<u8>) -> Result<(), Error>

Source§

impl<K: KeyEncode> KeyEncode for &K

Source§

fn encode_into(&self, buffer: &mut Vec<u8>) -> Result<(), Error>

Implementors§