pub struct Field<T = MetaForm>where
T: Form,{
pub name: Option<<T as Form>::String>,
pub ty: <T as Form>::Type,
pub type_name: Option<<T as Form>::String>,
pub docs: Vec<<T as Form>::String>,
}Expand description
A field of a struct-like data type.
Name is optional so it can represent both named and unnamed fields.
This can be a named field of a struct type or an enum struct variant, or an unnamed field of a tuple struct.
§Type name
The type_name field contains a string which is the name of the type of the
field as it appears in the source code. The exact contents and format of the
type name are not specified, but in practice will be the name of any valid
type for a field e.g.
- Concrete types e.g
"u32","bool","Foo"etc. - Type parameters e.g
"T","U" - Generic types e.g
"Vec<u32>","Vec<T>" - Associated types e.g.
"T::MyType","<T as MyTrait>::MyType" - Type aliases e.g.
"MyTypeAlias","MyTypeAlias<T>" - Other built in Rust types e.g. arrays, references etc.
Note that the type name doesn’t correspond to the underlying type of the field, unless using a concrete type directly. Any given type may be referred to by multiple field type names, when using generic type parameters and type aliases.
This is intended for informational and diagnostic purposes only. Although it is possible to infer certain properties e.g. whether a type name is a type alias, there are no guarantees provided, and the type name representation may change.
Fields§
§name: Option<<T as Form>::String>The name of the field. None for unnamed fields.
ty: <T as Form>::TypeThe type of the field.
type_name: Option<<T as Form>::String>The name of the type of the field as it appears in the source code.
docs: Vec<<T as Form>::String>Documentation
Implementations§
Source§impl<T> Field<T>where
T: Form,
impl<T> Field<T>where
T: Form,
Sourcepub fn builder() -> FieldBuilder<T>
pub fn builder() -> FieldBuilder<T>
Returns a new FieldBuilder for constructing a field.
Source§impl<T> Field<T>where
T: Form,
impl<T> Field<T>where
T: Form,
Sourcepub fn name(&self) -> Option<&<T as Form>::String>
👎Deprecated since 2.5.0: Prefer to access the fields directly; this getter will be removed in the next major version
pub fn name(&self) -> Option<&<T as Form>::String>
Returns the name of the field. None for unnamed fields.
Sourcepub fn ty(&self) -> &<T as Form>::Type
👎Deprecated since 2.5.0: Prefer to access the fields directly; this getter will be removed in the next major version
pub fn ty(&self) -> &<T as Form>::Type
Returns the type of the field.
Sourcepub fn type_name(&self) -> Option<&<T as Form>::String>
👎Deprecated since 2.5.0: Prefer to access the fields directly; this getter will be removed in the next major version
pub fn type_name(&self) -> Option<&<T as Form>::String>
Returns a string which is the name of the type of the field as it appears in the source code. The exact contents and format of the type name are not specified, but in practice will be the name of any valid type for a field. This is intended for informational and diagnostic purposes only.
Trait Implementations§
Source§impl<T> Decode for Field<T>
impl<T> Decode for Field<T>
Source§fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Field<T>, Error>where
__CodecInputEdqy: Input,
fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Field<T>, Error>where
__CodecInputEdqy: Input,
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Source§impl<'de, T> Deserialize<'de> for Field<T>
impl<'de, T> Deserialize<'de> for Field<T>
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Field<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Field<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<T> Encode for Field<T>
impl<T> Encode for Field<T>
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
Source§fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Source§impl IntoPortable for Field
impl IntoPortable for Field
Source§type Output = Field<PortableForm>
type Output = Field<PortableForm>
Self.Source§fn into_portable(
self,
registry: &mut Registry,
) -> <Field as IntoPortable>::Output
fn into_portable( self, registry: &mut Registry, ) -> <Field as IntoPortable>::Output
self to the portable form by using the registry for caching.Source§impl<T> Ord for Field<T>
impl<T> Ord for Field<T>
Source§impl<T> PartialOrd for Field<T>
impl<T> PartialOrd for Field<T>
Source§impl<T> Serialize for Field<T>
impl<T> Serialize for Field<T>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<T> EncodeLike for Field<T>
impl<T> Eq for Field<T>
impl<T> StructuralPartialEq for Field<T>where
T: Form,
Auto Trait Implementations§
impl<T> Freeze for Field<T>
impl<T> RefUnwindSafe for Field<T>
impl<T> Send for Field<T>
impl<T> Sync for Field<T>
impl<T> Unpin for Field<T>
impl<T> UnsafeUnpin for Field<T>
impl<T> UnwindSafe for Field<T>
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> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
Source§impl<T> DefensiveMax<T> for Twhere
T: PartialOrd,
impl<T> DefensiveMax<T> for Twhere
T: PartialOrd,
Source§fn defensive_max(self, other: T) -> T
fn defensive_max(self, other: T) -> T
Source§fn defensive_strict_max(self, other: T) -> T
fn defensive_strict_max(self, other: T) -> T
Source§impl<T> DefensiveMin<T> for Twhere
T: PartialOrd,
impl<T> DefensiveMin<T> for Twhere
T: PartialOrd,
Source§fn defensive_min(self, other: T) -> T
fn defensive_min(self, other: T) -> T
Source§fn defensive_strict_min(self, other: T) -> T
fn defensive_strict_min(self, other: T) -> T
Source§impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
Source§fn defensive_truncate_into(self) -> U
fn defensive_truncate_into(self) -> U
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.