pub struct Field {Show 14 fields
pub name: Name,
pub dtype: &'static str,
pub id: bool,
pub keyed: bool,
pub many: bool,
pub optional: bool,
pub unique: bool,
pub index: bool,
pub pick: Option<Pick>,
pub default: Option<DefaultFn>,
pub link: Option<Link>,
pub widget: fn() -> Widget,
pub parse: fn(&str, &mut dyn Writer) -> Result<(), StoreError>,
pub text: fn(&mut dyn Reader) -> String,
}Expand description
Spec for one column of a schema.
Fields§
§name: NameColumn name.
dtype: &'static strSQL type name (INTEGER, REAL, or TEXT).
id: boolAutoincrement primary key column.
keyed: boolPrimary key with a caller-supplied value.
many: boolVirtual many-to-many column, not stored inline.
optional: boolNullable column.
unique: boolUnique constraint.
index: boolIndexed column.
pick: Option<Pick>Fixed choice list, if any.
default: Option<DefaultFn>Default value factory, if any.
link: Option<Link>Reference to another table, if any.
widget: fn() -> WidgetWidget for this field.
parse: fn(&str, &mut dyn Writer) -> Result<(), StoreError>Parses raw text into the field’s value.
text: fn(&mut dyn Reader) -> StringRenders the field’s value as text.
Implementations§
Source§impl Field
impl Field
Sourcepub fn key<T: Storable + Show>(name: &'static str) -> Self
pub fn key<T: Storable + Show>(name: &'static str) -> Self
A caller-supplied primary key column.
Sourcepub fn default_value(self, value: impl Storable) -> Self
pub fn default_value(self, value: impl Storable) -> Self
Sets a static default Storable value.
Sourcepub fn default(
self,
make: impl Fn(&mut dyn Writer) + Send + Sync + 'static,
) -> Self
pub fn default( self, make: impl Fn(&mut dyn Writer) + Send + Sync + 'static, ) -> Self
Sets a default value factory.
Sourcepub fn references(self, target: &'static str) -> Self
pub fn references(self, target: &'static str) -> Self
Links to another table’s column ("table.column" or just "table").
Sourcepub fn reference(&self) -> Option<(Table, Name)>
pub fn reference(&self) -> Option<(Table, Name)>
The referenced (table, column) for a direct link, if any.
Sourcepub fn initial(&self) -> Value
pub fn initial(&self) -> Value
The field’s default as a Value, or Value::Null.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Field
impl !UnwindSafe for Field
impl Forget for Field
impl Freeze for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin 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
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 more