pub enum ToClient {
V1(ToClient),
V2(ToClient),
V3(ToClient),
V4(ToClient),
}Variants§
Trait Implementations§
Source§impl Versioned for ToClient
impl Versioned for ToClient
Source§const UPGRADES: &'static [Converter<Self>]
const UPGRADES: &'static [Converter<Self>]
UPGRADES[i] converts version i + 1 to version i + 2.Source§const DOWNGRADES: &'static [Converter<Self>]
const DOWNGRADES: &'static [Converter<Self>]
DOWNGRADES[i] converts version LATEST - i to version LATEST - i - 1.type Latest = ToClient
fn wrap_latest(latest: Self::Latest) -> Self
fn unwrap_latest(self) -> Result<Self::Latest>
Source§fn decode_version(version: u16, payload: Bytes) -> Result<Self, DecodeError>
fn decode_version(version: u16, payload: Bytes) -> Result<Self, DecodeError>
Decodes a body written at
version, which is never LATEST.Source§fn encode_version<S: Sink>(
&self,
version: u16,
out: &mut S,
) -> Result<(), EncodeError>
fn encode_version<S: Sink>( &self, version: u16, out: &mut S, ) -> Result<(), EncodeError>
Encodes the variant this value holds.
version is the version being written.Source§fn decode_body(body: Bytes, version: u16) -> Result<Self::Latest, DecodeError>
fn decode_body(body: Bytes, version: u16) -> Result<Self::Latest, DecodeError>
Decodes a body without a header, written at
version.Source§fn open_body(
body: Bytes,
version: u16,
) -> Result<View<<Self::Latest as Message>::Wire>, DecodeError>
fn open_body( body: Bytes, version: u16, ) -> Result<View<<Self::Latest as Message>::Wire>, DecodeError>
Views a body without a header, written at
version. Latest-version bodies are viewed in
place; older bodies are converted and re-encoded first.Source§fn encode_body<S>(
value: &Self::Latest,
version: u16,
out: &mut S,
) -> Result<(), EncodeError>where
S: Sink,
fn encode_body<S>(
value: &Self::Latest,
version: u16,
out: &mut S,
) -> Result<(), EncodeError>where
S: Sink,
Encodes
value at version without a header, converting it down if needed.Source§fn decode(bytes: Bytes) -> Result<Self::Latest, DecodeError>
fn decode(bytes: Bytes) -> Result<Self::Latest, DecodeError>
Decodes a payload with a version header to the latest version.
Source§fn open(
bytes: Bytes,
) -> Result<View<<Self::Latest as Message>::Wire>, DecodeError>
fn open( bytes: Bytes, ) -> Result<View<<Self::Latest as Message>::Wire>, DecodeError>
Views a payload with a version header. A latest-version payload is viewed without copying.
Source§fn seal<S>(
value: &Self::Latest,
version: u16,
out: &mut S,
) -> Result<(), EncodeError>where
S: Sink,
fn seal<S>(
value: &Self::Latest,
version: u16,
out: &mut S,
) -> Result<(), EncodeError>where
S: Sink,
Writes the version header and
value encoded at version into out.Source§fn sealed_len(value: &Self::Latest) -> usize
fn sealed_len(value: &Self::Latest) -> usize
The exact number of bytes
seal writes for value at the latest
version: the header plus the body. An older version converts the value first, so its length
is only known once it is encoded.Source§fn seal_to_vec(
value: &Self::Latest,
version: u16,
) -> Result<Vec<u8>, EncodeError>
fn seal_to_vec( value: &Self::Latest, version: u16, ) -> Result<Vec<u8>, EncodeError>
seal into a new Vec.Source§fn seal_to_bytes(
value: &Self::Latest,
version: u16,
) -> Result<Bytes, EncodeError>
fn seal_to_bytes( value: &Self::Latest, version: u16, ) -> Result<Bytes, EncodeError>
seal into a new Bytes, allocated once at the exact length for the
latest version.Source§fn seal_to_slice(
value: &Self::Latest,
version: u16,
out: &mut [u8],
) -> Result<usize, EncodeError>
fn seal_to_slice( value: &Self::Latest, version: u16, out: &mut [u8], ) -> Result<usize, EncodeError>
Seals
value at version into the front of out and returns the number of bytes
written. Fails with EncodeError::BufferTooSmall instead of panicking when out is too
short, and then writes nothing. Read moreSource§fn deserialize_with_embedded_version(
payload: &[u8],
) -> Result<Self::Latest, Error>
fn deserialize_with_embedded_version( payload: &[u8], ) -> Result<Self::Latest, Error>
decode from a slice, under vbare 0.1’s name. Copies payload once;
callers that hold Bytes should call decode instead.Source§fn serialize_with_embedded_version(
value: &Self::Latest,
version: u16,
) -> Result<Vec<u8>, Error>
fn serialize_with_embedded_version( value: &Self::Latest, version: u16, ) -> Result<Vec<u8>, Error>
seal_to_vec under vbare 0.1’s name. Takes the value by
reference, so callers no longer clone it into wrap_latest.Source§fn deserialize(payload: &[u8], version: u16) -> Result<Self::Latest, Error>
fn deserialize(payload: &[u8], version: u16) -> Result<Self::Latest, Error>
decode_body from a slice, under vbare 0.1’s name. Copies
payload once.Auto Trait Implementations§
impl !Freeze for ToClient
impl RefUnwindSafe for ToClient
impl Send for ToClient
impl Sync for ToClient
impl Unpin for ToClient
impl UnsafeUnpin for ToClient
impl UnwindSafe for ToClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more