pub struct Field {
pub name: String,
pub serde_name: String,
pub description: String,
pub deprecation_note: Option<String>,
pub type_ref: TypeReference,
pub required: bool,
pub flattened: bool,
pub transform_callback: String,
pub transform_callback_fn: Option<fn(&mut TypeReference, &Typespace)>,
}
Fields§
§name: String
Field name, should be a valid Rust field name identifier
serde_name: String
If a serialized name is not a valid Rust field name identifier then this defines the name of a field to be used in serialization
description: String
Rust docs for the field
deprecation_note: Option<String>
Deprecation note. If none, field is not deprecated. If present as empty string, field is deprecated without a note.
type_ref: TypeReference
Type of a field
required: bool
required and not nullable:
- field always present and not null / none
required and nullable:
- Rust: Option
, do not skip serializing if None - TypeScript: T | null, do not skip serializing if null
not required and not nullable:
- Rust: Option
, skip serializing if None - TypeScript: T | undefined, skip serializing if undefined
not required and nullable: serializers and deserializers are required to differentiate between missing fields and null / none fields
- Rust: reflectapi::Option
is enum with Undefined, None and Some variants - TypeScript: T | null | undefined
Default is false
flattened: bool
If serde flatten attribute is set on a field Default is false
transform_callback: String
§transform_callback_fn: Option<fn(&mut TypeReference, &Typespace)>
Implementations§
Source§impl Field
impl Field
pub fn new(name: String, type_ref: TypeReference) -> Self
pub fn with_required(self, required: bool) -> Self
pub fn name(&self) -> &str
pub fn is_named(&self) -> bool
pub fn is_unnamed(&self) -> bool
pub fn serde_name(&self) -> &str
pub fn description(&self) -> &str
pub fn deprecated(&self) -> bool
pub fn type_ref(&self) -> &TypeReference
pub fn required(&self) -> bool
pub fn flattened(&self) -> bool
pub fn transform_callback(&self) -> &str
pub fn transform_callback_fn( &self, ) -> Option<fn(&mut TypeReference, &Typespace)>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Field
impl<'de> Deserialize<'de> for Field
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
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
Mutably borrows from an owned value. Read more