Skip to main content

StringCodec

Struct StringCodec 

Source
pub struct StringCodec;
Expand description

Codec for the string proto type.

Singular decode reads the last length-delimited record at the field number and returns None when that record is not valid UTF-8, whatever earlier records hold. Records with other wire types are ignored.

Trait Implementations§

Source§

impl ExtensionCodec for StringCodec

Source§

type Value = String

The value type passed to ExtensionSet::set_extension.
Source§

type Output = Option<String>

The return type of ExtensionSet::extension.
Source§

fn decode(number: u32, fields: &UnknownFields) -> Option<String>

Decode this extension’s value from the extendee’s unknown fields.
Source§

fn try_encode( number: u32, value: String, fields: &mut UnknownFields, ) -> Result<(), EncodeError>

Encode value into the extendee’s unknown fields. Read more
Source§

fn encode(number: u32, value: Self::Value, fields: &mut UnknownFields)

Panicking wrapper over try_encode. Read more
Source§

impl SingularCodec for StringCodec

Source§

type Value = String

Source§

fn decode_one(data: &UnknownFieldData) -> Option<String>

Decode one value from one unknown-field record’s data. Read more
Source§

fn decode_packed(_bytes: &[u8], _out: &mut Vec<String>)

Decode all values from a packed LengthDelimited payload. Read more
Source§

fn try_encode_one(value: &String) -> Result<UnknownFieldData, EncodeError>

Encode one value as a single unknown-field record. Read more
Source§

fn decode_one_ctx( data: &UnknownFieldData, _ctx: DecodeContext<'_>, ) -> Option<Self::Value>

Decode one value under a decode context shared with the other records of the same field. Read more
Source§

fn encode_one(value: &Self::Value) -> UnknownFieldData

Panicking wrapper over try_encode_one. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.