Struct protobuf::reflect::FieldDescriptor[][src]

pub struct FieldDescriptor { /* fields omitted */ }

Field descriptor.

Can be used for runtime reflection.

Implementations

impl FieldDescriptor[src]

pub fn proto(&self) -> &'static FieldDescriptorProto[src]

Get .proto description of field

pub fn name(&self) -> &'static str[src]

Field name as specified in .proto file

pub fn json_name(&self) -> &str[src]

JSON field name.

Can be different from .proto field name.

See JSON mapping for details.

pub fn is_repeated(&self) -> bool[src]

If this field repeated?

pub fn has_field(&self, m: &dyn Message) -> bool[src]

Check if field is set in given message.

For repeated field or map field return true if collection is not empty.

Panics

If this field belongs to a different message type.

pub fn len_field(&self, m: &dyn Message) -> usize[src]

Return length of repeated field.

For singular field return 1 if field is set and 0 otherwise.

Panics

If this field belongs to a different message type.

pub fn get_message<'a>(&self, m: &'a dyn Message) -> &'a dyn Message[src]

Get message field or default instance if field is unset.

Panics

If this field belongs to a different message type or field type is not message.

pub fn get_enum(&self, m: &dyn Message) -> &'static EnumValueDescriptor[src]

Get enum field.

Panics

If this field belongs to a different message type or field type is not singular enum.

pub fn get_str<'a>(&self, m: &'a dyn Message) -> &'a str[src]

Get string field.

Panics

If this field belongs to a different message type or field type is not singular string.

pub fn get_bytes<'a>(&self, m: &'a dyn Message) -> &'a [u8]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get bytes field.

Panics

If this field belongs to a different message type or field type is not singular bytes.

pub fn get_u32(&self, m: &dyn Message) -> u32[src]

Get u32 field.

Panics

If this field belongs to a different message type or field type is not singular u32.

pub fn get_u64(&self, m: &dyn Message) -> u64[src]

Get u64 field.

Panics

If this field belongs to a different message type or field type is not singular u64.

pub fn get_i32(&self, m: &dyn Message) -> i32[src]

Get i32 field.

Panics

If this field belongs to a different message type or field type is not singular i32.

pub fn get_i64(&self, m: &dyn Message) -> i64[src]

Get i64 field.

Panics

If this field belongs to a different message type or field type is not singular i64.

pub fn get_bool(&self, m: &dyn Message) -> bool[src]

Get bool field.

Panics

If this field belongs to a different message type or field type is not singular bool.

pub fn get_f32(&self, m: &dyn Message) -> f32[src]

Get float field.

Panics

If this field belongs to a different message type or field type is not singular float.

pub fn get_f64(&self, m: &dyn Message) -> f64[src]

Get double field.

Panics

If this field belongs to a different message type or field type is not singular double.

pub fn get_reflect<'a>(&self, m: &'a dyn Message) -> ReflectFieldRef<'a>[src]

Get field of any type.

Panics

If this field belongs to a different message type.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.