pub struct Field { /* private fields */ }Expand description
One named field: a type, whether it may be null and whether it must be present, its constraints, and optionally the source’s own name for the type, a description and metadata.
Implementations§
Source§impl Field
impl Field
Sourcepub fn required(self, required: bool) -> Self
pub fn required(self, required: bool) -> Self
Whether a value must be present (default false): JSON Schema’s
required, SQL’s NOT NULL, a non-nullable Arrow field.
Sourcepub fn with_native_type(self, native: impl Into<String>) -> Self
pub fn with_native_type(self, native: impl Into<String>) -> Self
The source format’s own name for the type, kept as written
(Int32, VARCHAR(20), string | null). A schema tree shows it in
place of the model’s type.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
A description, as the source gives it.
Sourcepub fn with_constraint(self, constraint: Constraint) -> Self
pub fn with_constraint(self, constraint: Constraint) -> Self
Add a constraint.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a metadata entry (Arrow’s field metadata).
Sourcepub fn with_kind(self, kind: FieldKind) -> Self
pub fn with_kind(self, kind: FieldKind) -> Self
How the field relates to its parent (default FieldKind::Field).
Sourcepub fn with_reference(self, reference: impl Into<String>) -> Self
pub fn with_reference(self, reference: impl Into<String>) -> Self
The named definition the type was found through (#/$defs/item).
Sourcepub fn with_unexpanded(self, unexpanded: Unexpanded) -> Self
pub fn with_unexpanded(self, unexpanded: Unexpanded) -> Self
Mark the type as named by a reference that is not drawn in place.
Sourcepub fn data_type_mut(&mut self) -> &mut DataType
pub fn data_type_mut(&mut self) -> &mut DataType
The type, to change in place.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Whether the field may be null.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Whether a value must be present.
Sourcepub fn native_type(&self) -> Option<&str>
pub fn native_type(&self) -> Option<&str>
The source’s own type name, if one was recorded.
Sourcepub fn type_label(&self) -> String
pub fn type_label(&self) -> String
The type as a tree shows it: the native type, else the model’s.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
The description, if any.
Sourcepub fn constraints(&self) -> &[Constraint]
pub fn constraints(&self) -> &[Constraint]
The constraints, in the order the source gives them.
Sourcepub fn constraints_mut(&mut self) -> &mut Vec<Constraint>
pub fn constraints_mut(&mut self) -> &mut Vec<Constraint>
The constraints, to change in place.
Sourcepub fn constraint(&self, key: &str) -> Option<&Constraint>
pub fn constraint(&self, key: &str) -> Option<&Constraint>
The first constraint with key (Constraint::key).
Sourcepub fn enum_values(&self) -> Option<&[Literal]>
pub fn enum_values(&self) -> Option<&[Literal]>
The listed values, when the field is an enum.
Sourcepub fn default_value(&self) -> Option<&Literal>
pub fn default_value(&self) -> Option<&Literal>
The default value, if any.
Sourcepub fn is_primary_key(&self) -> bool
pub fn is_primary_key(&self) -> bool
Whether the field is (part of) the primary key.
Sourcepub fn references(&self) -> Option<&ForeignKey>
pub fn references(&self) -> Option<&ForeignKey>
What the field refers to, if it is a foreign key.
Sourcepub fn unexpanded(&self) -> Option<&Unexpanded>
pub fn unexpanded(&self) -> Option<&Unexpanded>
Why the type is not drawn in place, when it is not.
Sourcepub fn children(&self) -> impl Iterator<Item = &Field>
pub fn children(&self) -> impl Iterator<Item = &Field>
The nested fields (DataType::children).
Trait Implementations§
impl Eq for Field
Source§impl FromIterator<Field> for Schema
impl FromIterator<Field> for Schema
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.