Trait ockam_multiaddr::Codec
source · pub trait Codec: Send + Sync {
// Required methods
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§
sourcefn split_str<'a>(
&self,
prefix: &str,
input: &'a str
) -> Result<(Checked<&'a str>, &'a str), Error>
fn split_str<'a>( &self, prefix: &str, input: &'a str ) -> Result<(Checked<&'a str>, &'a str), Error>
Split input string into the value and the remainder.
sourcefn split_bytes<'a>(
&self,
code: Code,
input: &'a [u8]
) -> Result<(Checked<&'a [u8]>, &'a [u8]), Error>
fn split_bytes<'a>( &self, code: Code, input: &'a [u8] ) -> Result<(Checked<&'a [u8]>, &'a [u8]), Error>
Split input bytes into the value and the remainder.
sourcefn is_valid_bytes(&self, code: Code, value: Checked<&[u8]>) -> bool
fn is_valid_bytes(&self, code: Code, value: Checked<&[u8]>) -> bool
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.