pub struct FieldDefinition {
pub name: String,
pub field_type: FieldType,
pub description: Option<String>,
pub default: Option<Value>,
pub constraints: Vec<Constraint>,
pub nullable: bool,
}Expand description
Field definition with type and constraints
Fields§
§name: StringField name
field_type: FieldTypeField type
description: Option<String>Human-readable description
default: Option<Value>Default value (as JSON)
constraints: Vec<Constraint>Validation constraints
nullable: boolWhether this field is nullable
Implementations§
Source§impl FieldDefinition
impl FieldDefinition
Sourcepub fn new(name: impl Into<String>, field_type: FieldType) -> Self
pub fn new(name: impl Into<String>, field_type: FieldType) -> Self
Create a new field definition
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Add a description
Sourcepub fn with_default(self, default: Value) -> Self
pub fn with_default(self, default: Value) -> Self
Set default value
Sourcepub fn with_constraint(self, constraint: Constraint) -> Self
pub fn with_constraint(self, constraint: Constraint) -> Self
Add a constraint
Trait Implementations§
Source§impl Clone for FieldDefinition
impl Clone for FieldDefinition
Source§fn clone(&self) -> FieldDefinition
fn clone(&self) -> FieldDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FieldDefinition
impl Debug for FieldDefinition
Source§impl<'de> Deserialize<'de> for FieldDefinition
impl<'de> Deserialize<'de> for FieldDefinition
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
Source§impl PartialEq for FieldDefinition
impl PartialEq for FieldDefinition
Source§impl Serialize for FieldDefinition
impl Serialize for FieldDefinition
impl StructuralPartialEq for FieldDefinition
Auto Trait Implementations§
impl Freeze for FieldDefinition
impl RefUnwindSafe for FieldDefinition
impl Send for FieldDefinition
impl Sync for FieldDefinition
impl Unpin for FieldDefinition
impl UnsafeUnpin for FieldDefinition
impl UnwindSafe for FieldDefinition
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.