Module field

Source
Expand description

Accessor and extension traits for fields.

§Accessor Traits

§For structs and enums

The FieldType trait,for querying the type of a field,

§For structs

The GetField, GetFieldMut, IntoField accessor traits,that define how a field is accessed.

IntoFieldMut,a trait alias for GetFieldMut + IntoField.

§For enums

The GetVariantField, GetVariantFieldMut, IntoVariantField accessor traits,that define how a variant field is accessed.

IntoVariantFieldMut, a trait alias for GetVariantFieldMut + IntoVariantField.

§Destruction traits

These traits allow a type to release resources (ie:memory) when a type is converted into multiple fields by value:

  • DropFields: Used to drop the fields that weren’t moved out, and run code before they’re moved.

  • PrePostDropFields: Used to add code that runs before and after an automatically generated DropFields implementation.

§Rev* traits

The Rev* traits,implemented by field paths,accessing field(s) from the passed-in type.

There are two kinds of Rev* traits,single field and multi field traits.

The StructuralExt trait uses the Rev* impls of the passed-in path to access the fields in Self.

§Single Field traits

Which are RevGetFieldImpl, RevGetFieldMutImpl, and RevIntoFieldImpl, mirroring the regular field accessor traits.

The RevMoveOutFieldImpl trait mirrors the Into*Field::move_out_*field_ method. This is a separate trait because not all single field paths are valid for moving out a field,they have to refer to a shallow field.

§Multiple field traits

For bounds to access multiple fields at once, there’s RevGetMultiField,RevGetMultiFieldMut,and RevIntoMultiField.

For implementing a way to access multiple fields there’s RevGetMultiFieldImpl,RevGetMultiFieldMutImpl,and RevIntoMultiFieldImpl.

There is the RevMoveOutMultiFieldImpl trait for moving out multiple shallow fields, useful for implementing RevIntoMultiFieldImpl.

§type aliases

The GetFieldType, GetFieldType2, GetFieldType3, GetFieldType4 type aliases allow querying the type of a field up to 4 levels of nesting.

The GetVariantFieldType for querying the type of an enum variant field, most useful when the name of the variant and the field are passed separately.

The RevGetFieldType type alias gets the type of a nested field (which one is determined by the field path).

The RevFieldErrOut type alias allows querying the RevGetField::Err associated type, useful when delegating the Rev*Impl traits.

§Errors

The errors module contains the error-related items used in Rev* trait impls.

§Normalize Fields

NormalizeFields transforms the Result<T,_>s from inside a type returned by Rev traits into either an Option<T> or a T depending on its error type.

NormalizeFieldsOut The type that Foo is converted into when calling Foo::normalize_fields( foo ).

Re-exports§

pub use self::errors::CombinedErrs;
pub use self::errors::CombinedErrsOut;
pub use self::errors::FailedAccess;
pub use self::errors::InfallibleAccess;
pub use self::errors::IntoFieldErr;
pub use self::errors::IsFieldErr;
pub use self::multi_fields::RevGetMultiField;
pub use self::multi_fields::RevGetMultiFieldImpl;
pub use self::multi_fields::RevGetMultiFieldMut;
pub use self::multi_fields::RevGetMultiFieldMutImpl;
pub use self::multi_fields::RevGetMultiFieldMutOut;
pub use self::multi_fields::RevGetMultiFieldMutRaw;
pub use self::multi_fields::RevGetMultiFieldOut;
pub use self::multi_fields::RevIntoMultiField;
pub use self::multi_fields::RevIntoMultiFieldImpl;
pub use self::multi_fields::RevIntoMultiFieldOut;
pub use self::ownership::DropFields;
pub use self::ownership::FieldBit;
pub use self::ownership::MovedOutFields;
pub use self::ownership::PrePostDropFields;
pub use self::rev_get_field::OptRevGetField;
pub use self::rev_get_field::OptRevGetFieldMut;
pub use self::rev_get_field::OptRevIntoField;
pub use self::rev_get_field::OptRevIntoFieldMut;
pub use self::rev_get_field::OptRevIntoFieldRef;
pub use self::rev_get_field::RevFieldErr;
pub use self::rev_get_field::RevFieldErrOut;
pub use self::rev_get_field::RevFieldType;
pub use self::rev_get_field::RevGetField;
pub use self::rev_get_field::RevGetFieldImpl;
pub use self::rev_get_field::RevGetFieldMut;
pub use self::rev_get_field::RevGetFieldMutImpl;
pub use self::rev_get_field::RevGetFieldType;
pub use self::rev_get_field::RevIntoField;
pub use self::rev_get_field::RevIntoFieldImpl;
pub use self::rev_get_field::RevIntoFieldMut;
pub use self::rev_get_field::RevIntoFieldRef;
pub use self::rev_get_field::RevMoveOutFieldImpl;

Modules§

errors
Field-accessor-related error types and traits
multi_fields
Contains traits for accessing multiple fields at once.
ownership
Items for moving out fields out of a type,and dropping it afterwards.
rev_get_field
Contains traits implemented on field paths,taking Structural types as parameters.

Traits§

FieldType
For querying the type of the FieldPath field.
GetField
Provides shared access to the FieldName field.
GetFieldMut
Allows accessing the FieldName field mutably.
GetVariantField
Provides shared access to an enum variant field.
GetVariantFieldMut
Provides shared and mutable access to an enum variant field.
IntoField
Converts this type into its FieldName field by value.
IntoFieldMut
A bound for shared, mutable,and by-value access to the FieldName field.
IntoVariantField
Provides shared and by-value access to an enum variant field.
IntoVariantFieldMut
A bound for shared,mutable,and by-value access to the field F inside of the V variant.
NormalizeFields
Converts the Result<T,E> representation of accessed fields to either T or Option<T>

Type Aliases§

GetFieldRawMutFn
The type of GetFieldMut::get_field_raw_mut
GetFieldType
Queries the type of a field.
GetFieldType2
Queries the type of a double nested field (eg:.a.b).
GetFieldType3
Queries the type of a triple nested field (eg:.a.b.c).
GetFieldType4
Queries the type of a quadruple nested field (eg:.a.b.c.d).
GetVFieldRawMutFn
The function pointer type for the GetVariantFieldMut::get_vfield_raw_mut_ method.
GetVariantFieldType
Gets the type of a variant field, most useful when the variant and field TStrs are passed separately.
NormalizeFieldsOut
The type This is converted into when calling .normalize_fields().