pub struct FieldDef {
pub name: String,
pub kind: FieldKind,
pub required: bool,
pub unique: bool,
pub indexed: bool,
pub default: Option<Value>,
}Expand description
One declared column.
Fields§
§name: StringLowercase snake-case identifier, unique within the table.
kind: FieldKind§required: boolNOT NULL in the generated DDL. A required field with a default
may still be left out of a write: the database supplies the value.
unique: boolUNIQUE in the generated DDL. Uniqueness is enforced by the
database, never by the row validator, because it reads other rows.
indexed: boolGets its own CREATE INDEX.
default: Option<Value>Literal default, checked against kind by Schema::validate.
Implementations§
Source§impl FieldDef
impl FieldDef
Sourcepub fn new(name: impl Into<String>, kind: FieldKind) -> Self
pub fn new(name: impl Into<String>, kind: FieldKind) -> Self
An optional field of kind, with no default and no index.
pub fn required(self) -> Self
pub fn unique(self) -> Self
pub fn indexed(self) -> Self
pub fn default_value(self, value: Value) -> Self
Sourcepub fn must_be_present(&self) -> bool
pub fn must_be_present(&self) -> bool
Whether a write must carry this field. A default satisfies
required, so only a required field without one has to be sent.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FieldDef
impl<'de> Deserialize<'de> for FieldDef
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for FieldDef
Auto Trait Implementations§
impl Freeze for FieldDef
impl RefUnwindSafe for FieldDef
impl Send for FieldDef
impl Sync for FieldDef
impl Unpin for FieldDef
impl UnsafeUnpin for FieldDef
impl UnwindSafe for FieldDef
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