[−][src]Struct scale_info::Field
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.
Implementations
impl Field
[src]
pub fn new(
name: Option<&'static str>,
ty: MetaType,
type_name: &'static str
) -> Self
[src]
name: Option<&'static str>,
ty: MetaType,
type_name: &'static str
) -> Self
Creates a new field.
Use this constructor if you want to instantiate from a given meta type.
pub fn named_of<T: ?Sized>(name: &'static str, type_name: &'static str) -> Field where
T: TypeInfo + 'static,
[src]
T: TypeInfo + 'static,
Creates a new named field.
Use this constructor if you want to instantiate from a given compile-time type.
pub fn unnamed_of<T: ?Sized>(type_name: &'static str) -> Field where
T: TypeInfo + 'static,
[src]
T: TypeInfo + 'static,
Creates a new unnamed field.
Use this constructor if you want to instantiate an unnamed field from a given compile-time type.
impl<T> Field<T> where
T: Form,
[src]
T: Form,
pub fn name(&self) -> Option<&T::String>
[src]
Returns the name of the field. None for unnamed fields.
pub fn ty(&self) -> &T::Type
[src]
Returns the type of the field.
pub fn type_name(&self) -> &T::String
[src]
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
impl<T: Clone + Form> Clone for Field<T> where
T::String: Clone,
T::Type: Clone,
T::String: Clone,
[src]
T::String: Clone,
T::Type: Clone,
T::String: Clone,
impl<T: Debug + Form> Debug for Field<T> where
T::String: Debug,
T::Type: Debug,
T::String: Debug,
[src]
T::String: Debug,
T::Type: Debug,
T::String: Debug,
impl<T: Form> Decode for Field<T> where
Option<T::String>: Decode,
Option<T::String>: Decode,
T::Type: Decode,
T::Type: Decode,
T::String: Decode,
T::String: Decode,
[src]
Option<T::String>: Decode,
Option<T::String>: Decode,
T::Type: Decode,
T::Type: Decode,
T::String: Decode,
T::String: Decode,
fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
[src]
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
pub fn skip<I>(input: &mut I) -> Result<(), Error> where
I: Input,
[src]
I: Input,
pub fn encoded_fixed_size() -> Option<usize>
[src]
impl<T: Form> Encode for Field<T> where
Option<T::String>: Encode,
Option<T::String>: Encode,
T::Type: Encode,
T::Type: Encode,
T::String: Encode,
T::String: Encode,
[src]
Option<T::String>: Encode,
Option<T::String>: Encode,
T::Type: Encode,
T::Type: Encode,
T::String: Encode,
T::String: Encode,
fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
[src]
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
pub fn size_hint(&self) -> usize
[src]
pub fn encode(&self) -> Vec<u8, Global>ⓘ
[src]
pub fn using_encoded<R, F>(&self, f: F) -> R where
F: FnOnce(&[u8]) -> R,
[src]
F: FnOnce(&[u8]) -> R,
pub fn encoded_size(&self) -> usize
[src]
impl<T: Form> EncodeLike<Field<T>> for Field<T> where
Option<T::String>: Encode,
Option<T::String>: Encode,
T::Type: Encode,
T::Type: Encode,
T::String: Encode,
T::String: Encode,
[src]
Option<T::String>: Encode,
Option<T::String>: Encode,
T::Type: Encode,
T::Type: Encode,
T::String: Encode,
T::String: Encode,
impl<T: Eq + Form> Eq for Field<T> where
T::String: Eq,
T::Type: Eq,
T::String: Eq,
[src]
T::String: Eq,
T::Type: Eq,
T::String: Eq,
impl IntoPortable for Field
[src]
type Output = Field<PortableForm>
The portable version of Self
.
fn into_portable(self, registry: &mut Registry) -> Self::Output
[src]
impl<T: Ord + Form> Ord for Field<T> where
T::String: Ord,
T::Type: Ord,
T::String: Ord,
[src]
T::String: Ord,
T::Type: Ord,
T::String: Ord,
fn cmp(&self, other: &Field<T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T: PartialEq + Form> PartialEq<Field<T>> for Field<T> where
T::String: PartialEq,
T::Type: PartialEq,
T::String: PartialEq,
[src]
T::String: PartialEq,
T::Type: PartialEq,
T::String: PartialEq,
impl<T: PartialOrd + Form> PartialOrd<Field<T>> for Field<T> where
T::String: PartialOrd,
T::Type: PartialOrd,
T::String: PartialOrd,
[src]
T::String: PartialOrd,
T::Type: PartialOrd,
T::String: PartialOrd,
fn partial_cmp(&self, other: &Field<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Field<T>) -> bool
[src]
fn le(&self, other: &Field<T>) -> bool
[src]
fn gt(&self, other: &Field<T>) -> bool
[src]
fn ge(&self, other: &Field<T>) -> bool
[src]
impl<T: Form> StructuralEq for Field<T>
[src]
impl<T: Form> StructuralPartialEq for Field<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Field<T> where
<T as Form>::String: RefUnwindSafe,
<T as Form>::Type: RefUnwindSafe,
[src]
<T as Form>::String: RefUnwindSafe,
<T as Form>::Type: RefUnwindSafe,
impl<T> Send for Field<T> where
<T as Form>::String: Send,
<T as Form>::Type: Send,
[src]
<T as Form>::String: Send,
<T as Form>::Type: Send,
impl<T> Sync for Field<T> where
<T as Form>::String: Sync,
<T as Form>::Type: Sync,
[src]
<T as Form>::String: Sync,
<T as Form>::Type: Sync,
impl<T> Unpin for Field<T> where
<T as Form>::String: Unpin,
<T as Form>::Type: Unpin,
[src]
<T as Form>::String: Unpin,
<T as Form>::Type: Unpin,
impl<T> UnwindSafe for Field<T> where
<T as Form>::String: UnwindSafe,
<T as Form>::Type: UnwindSafe,
[src]
<T as Form>::String: UnwindSafe,
<T as Form>::Type: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<S> Codec for S where
S: Encode + Decode,
[src]
S: Encode + Decode,
impl<T> DecodeAll for T where
T: Decode,
[src]
T: Decode,
impl<T> DecodeLimit for T where
T: Decode,
[src]
T: Decode,
pub fn decode_all_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>
[src]
pub fn decode_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>
[src]
impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ mut T> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Arc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Box<T, Global>> for T where
T: Encode,
[src]
T: Encode,
impl<'a, T> EncodeLike<Cow<'a, T>> for T where
T: Encode + ToOwned,
[src]
T: Encode + ToOwned,
impl<T> EncodeLike<Rc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> From<T> for T
[src]
impl<S> FullCodec for S where
S: Decode + FullEncode,
[src]
S: Decode + FullEncode,
impl<S> FullEncode for S where
S: Encode + EncodeLike<S>,
[src]
S: Encode + EncodeLike<S>,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> KeyedVec for T where
T: Codec,
[src]
T: Codec,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,