Trait ockam_multiaddr::Codec
source · [−]pub trait Codec: Send + Sync {
fn split_str<'a>(
&self,
prefix: &str,
input: &'a str
) -> Result<(Checked<&'a str>, &'a str), Error>;
fn split_bytes<'a>(
&self,
code: Code,
input: &'a [u8]
) -> Result<(Checked<&'a [u8]>, &'a [u8]), Error>;
fn is_valid_bytes(&self, code: Code, value: Checked<&[u8]>) -> bool;
fn write_bytes(
&self,
val: &ProtoValue<'_>,
buf: &mut dyn Buffer
) -> Result<(), Error>;
fn transcode_str(
&self,
prefix: &str,
value: Checked<&str>,
buf: &mut dyn Buffer
) -> Result<(), Error>;
fn transcode_bytes(
&self,
code: Code,
value: Checked<&[u8]>,
f: &mut Formatter<'_>
) -> Result<(), Error>;
}
Expand description
Type that understands how to read and write Protocol
s.
Required Methods
Split input string into the value and the remainder.
Split input bytes into the value and the remainder.
Are the given input bytes valid w.r.t. the code?
sourcefn write_bytes(
&self,
val: &ProtoValue<'_>,
buf: &mut dyn Buffer
) -> Result<(), Error>
fn write_bytes(
&self,
val: &ProtoValue<'_>,
buf: &mut dyn Buffer
) -> Result<(), Error>
Write a protocol value to the given buffer.
Decode the string value and encode it into the buffer.