Struct mesh_protobuf::protofile::FieldType
source · pub struct FieldType<'a> { /* private fields */ }
Expand description
The description of a field type.
Implementations§
source§impl<'a> FieldType<'a>
impl<'a> FieldType<'a>
sourcepub const fn repeated(self) -> Self
pub const fn repeated(self) -> Self
Returns a repeated version of this field type.
Panics if the field type is already a sequence type.
sourcepub const fn optional(self) -> Self
pub const fn optional(self) -> Self
Returns a optional version of this field type.
Panics if the field type is already a sequence type.
sourcepub const fn annotate(self, annotation: &'a str) -> Self
pub const fn annotate(self, annotation: &'a str) -> Self
Sets an annotation to show up in the .proto file.
sourcepub const fn map(kv: &'a [FieldType<'a>; 2]) -> Self
pub const fn map(kv: &'a [FieldType<'a>; 2]) -> Self
Returns a map type.
If key
is not a builtin numeric scalar or string type, or if value
is an optional or repeated type, then this will result in a repeated
tuple instead of a protobuf map
type. The encodings for these are the
same, but .proto
map
types are constrained to mappings from scalars
to non-optional/repeated scalars and messages.
sourcepub const fn message(f: fn() -> MessageDescription<'a>) -> Self
pub const fn message(f: fn() -> MessageDescription<'a>) -> Self
Returns a field type for a message whose top-level descriptor is
returned by f
.
This is abstracted through a function to allow for recursive types.
Currently Rust does not allow a const
to refer to a static
, but it
does allow a const
to refer to a function that returns a &'static
.
sourcepub const fn local(name: &'a str) -> Self
pub const fn local(name: &'a str) -> Self
Returns a field type for a local message type with name
.
sourcepub const fn builtin(name: &'a str) -> Self
pub const fn builtin(name: &'a str) -> Self
Returns a field type for a builtin type, such as uint32
.
sourcepub const fn tuple(field_types: &'a [Self]) -> Self
pub const fn tuple(field_types: &'a [Self]) -> Self
Returns a field type for an anonymous tuple.
sourcepub const fn external(name: &'a str, import_path: &'static str) -> Self
pub const fn external(name: &'a str, import_path: &'static str) -> Self
Returns a field type for an external type with the given fully-qualified name and protoc import path.
sourcepub const fn is_sequence(&self) -> bool
pub const fn is_sequence(&self) -> bool
Returns true if this is a sequence type (optional or repeated).
Trait Implementations§
impl<'a> Copy for FieldType<'a>
impl<'a> Eq for FieldType<'a>
impl<'a> StructuralPartialEq for FieldType<'a>
Auto Trait Implementations§
impl<'a> Freeze for FieldType<'a>
impl<'a> RefUnwindSafe for FieldType<'a>
impl<'a> Send for FieldType<'a>
impl<'a> Sync for FieldType<'a>
impl<'a> Unpin for FieldType<'a>
impl<'a> UnwindSafe for FieldType<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)