FieldValue

Enum FieldValue 

Source
pub enum FieldValue<L> {
    Varint(Varint),
    I32([u8; 4]),
    I64([u8; 8]),
    Len(L),
}
Expand description

A raw field value read from the wire

This represents the raw bytes of a field value without semantic interpretation. The caller is responsible for converting these raw values to the appropriate types based on the field’s schema definition.

L is the type for length-delimited values (Len variant).

  • For owned data (from std::io::Read): use Vec<u8>
  • For borrowed data (from slices): use &'a [u8]

Variants§

§

Varint(Varint)

Variable-width integers (Int32, Int64, UInt32, UInt64, SInt32, SInt64, Bool, Enum)

§

I32([u8; 4])

32-bit fixed-width values (Fixed32, SFixed32, Float)

§

I64([u8; 8])

64-bit fixed-width values (Fixed64, SFixed64, Double)

§

Len(L)

Length-delimited values (String, Bytes, embedded messages, packed repeated fields)

Implementations§

Source§

impl<L> FieldValue<L>

Source

pub fn from_varint(varint: Varint) -> Self

Create a field value from a Varint

Source

pub fn from_uint64(value: u64) -> Self

Create a field value from a UInt64 protobuf type

Source

pub fn from_uint32(value: u32) -> Self

Create a field value from a UInt32 protobuf type

Source

pub fn from_sint64(value: i64) -> Self

Create a field value from a SInt64 protobuf type (ZigZag encoded)

Source

pub fn from_sint32(value: i32) -> Self

Create a field value from a SInt32 protobuf type (ZigZag encoded)

Source

pub fn from_int64(value: i64) -> Self

Create a field value from an Int64 protobuf type (non-ZigZag)

Source

pub fn from_int32(value: i32) -> Self

Create a field value from an Int32 protobuf type (non-ZigZag)

Source

pub fn from_bool(value: bool) -> Self

Create a field value from a Bool protobuf type

Source

pub fn from_fixed32(value: u32) -> Self

Create a field value from a Fixed32 protobuf type

Source

pub fn from_sfixed32(value: i32) -> Self

Create a field value from a SFixed32 protobuf type

Source

pub fn from_float(value: f32) -> Self

Create a field value from a Float protobuf type

Source

pub fn from_fixed64(value: u64) -> Self

Create a field value from a Fixed64 protobuf type

Source

pub fn from_sfixed64(value: i64) -> Self

Create a field value from a SFixed64 protobuf type

Source

pub fn from_double(value: f64) -> Self

Create a field value from a Double protobuf type

Source

pub fn encoded_size(&self) -> usize
where L: AsRef<[u8]>,

Calculate the encoded size of this field value in bytes (excluding the tag)

For Len values, this includes the length varint plus the data bytes.

Trait Implementations§

Source§

impl<L: Clone> Clone for FieldValue<L>

Source§

fn clone(&self) -> FieldValue<L>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug> Debug for FieldValue<L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<L: PartialEq> PartialEq for FieldValue<L>

Source§

fn eq(&self, other: &FieldValue<L>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<L> StructuralPartialEq for FieldValue<L>

Auto Trait Implementations§

§

impl<L> Freeze for FieldValue<L>
where L: Freeze,

§

impl<L> RefUnwindSafe for FieldValue<L>
where L: RefUnwindSafe,

§

impl<L> Send for FieldValue<L>
where L: Send,

§

impl<L> Sync for FieldValue<L>
where L: Sync,

§

impl<L> Unpin for FieldValue<L>
where L: Unpin,

§

impl<L> UnwindSafe for FieldValue<L>
where L: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.