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) -> FieldType<'a>
pub const fn repeated(self) -> FieldType<'a>
Returns a repeated version of this field type.
Panics if the field type is already a sequence type.
Sourcepub const fn optional(self) -> FieldType<'a>
pub const fn optional(self) -> FieldType<'a>
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) -> FieldType<'a>
pub const fn annotate(self, annotation: &'a str) -> FieldType<'a>
Sets an annotation to show up in the .proto file.
Sourcepub const fn map(kv: &'a [FieldType<'a>; 2]) -> FieldType<'a>
pub const fn map(kv: &'a [FieldType<'a>; 2]) -> FieldType<'a>
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>) -> FieldType<'a>
pub const fn message(f: fn() -> MessageDescription<'a>) -> FieldType<'a>
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) -> FieldType<'a>
pub const fn local(name: &'a str) -> FieldType<'a>
Returns a field type for a local message type with name
.
Sourcepub const fn builtin(name: &'a str) -> FieldType<'a>
pub const fn builtin(name: &'a str) -> FieldType<'a>
Returns a field type for a builtin type, such as uint32
.
Sourcepub const fn tuple(field_types: &'a [FieldType<'a>]) -> FieldType<'a>
pub const fn tuple(field_types: &'a [FieldType<'a>]) -> FieldType<'a>
Returns a field type for an anonymous tuple.
Sourcepub const fn external(name: &'a str, import_path: &'static str) -> FieldType<'a>
pub const fn external(name: &'a str, import_path: &'static str) -> FieldType<'a>
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).