pub trait Model: Sized + 'static {
type Paths<R>: Clone;
const SHAPE: Shape = crate::Shape::Value;
const CHECKS: bool = false;
const OPS: bool = false;
const NULLABLE: bool = false;
const SCALAR: bool = false;
const TABLE: &'static ModelTable = _;
Show 25 methods
// Required methods
fn paths_at<R>(path: Path<R, Self>) -> Self::Paths<R>;
fn to_json(&self) -> Value;
fn from_json(value: &Value) -> Result<Self, ModelError>;
fn load(
doc: &Doc,
value: &Value<'_>,
id: &ObjId,
) -> Result<Self, ModelError>;
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>;
// Provided methods
fn edit(
doc: &mut Doc,
slot: Slot<'_>,
path: &[Segment],
op: &EditOp,
cx: &mut ActionCx,
) -> Result<(), ModelError> { ... }
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>) { ... }
fn nested_collections(&self) -> Vec<ItemCollection> { ... }
fn value_schema() -> Value { ... }
fn field_type(types: &mut TypeSet) -> FieldType { ... }
fn read_whole(&mut self, doc: &Doc) -> Result<(), ModelError> { ... }
fn check(&self) -> Result<(), Refusal> { ... }
fn label(&self) -> Option<String> { ... }
fn op_coalesces(
path: &[Segment],
previous: &Value,
next: &Value,
) -> Option<bool> { ... }
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool> { ... }
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription> { ... }
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place> { ... }
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>) { ... }
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>
where Self: 'static { ... }
fn missing() -> Result<Self, ModelError> { ... }
fn fresh(&self, encoding: TextEncoding) -> Fresh { ... }
fn stores_as(&self, before: &Self) -> bool { ... }
fn store_changed(
&self,
before: &Self,
doc: &mut Doc,
slot: Slot<'_>,
dirty: &Delta,
) -> Result<(), ModelError> { ... }
fn refresh(
&mut self,
doc: &Doc,
value: &Value<'_>,
id: &ObjId,
delta: &Delta,
) -> Result<(), ModelError> { ... }
fn collect_text(&self, _out: &mut Vec<String>) { ... }
}Expand description
A typed value stored in a CRDT document. See the module docs.
Provided Associated Constants§
Sourceconst SHAPE: Shape = crate::Shape::Value
const SHAPE: Shape = crate::Shape::Value
How the value is laid out in the document; see Shape.
Types written whole keep the default.
Sourceconst CHECKS: bool = false
const CHECKS: bool = false
Whether this type or any value inside it has a #[model(check)]
invariant; Self::check has nothing to do otherwise.
Sourceconst OPS: bool = false
const OPS: bool = false
Whether this type or a value inside it has a vocabulary of its own
(Operations, rich text’s): a record routes
those edits’ gestures, landing places and schemas only into such
fields, and never instantiates the routing for the others.
Sourceconst NULLABLE: bool = false
const NULLABLE: bool = false
Whether null is a value of the type: an absent Option. A field
edit setting any other type to null is refused.
Sourceconst TABLE: &'static ModelTable = _
const TABLE: &'static ModelTable = _
The type’s functions as data, which a record holding it reaches it
through (crate::table): by default its own functions, erased.
Required Associated Types§
Required Methods§
Sourcefn to_json(&self) -> Value
fn to_json(&self) -> Value
The value as JSON: what EditOp::Set carries and history shows.
Sourcefn from_json(value: &Value) -> Result<Self, ModelError>
fn from_json(value: &Value) -> Result<Self, ModelError>
Sourcefn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
Read from the value a parent found in its slot.
§Errors
Returns ModelError when the stored value has another shape.
Provided Methods§
Sourcefn edit(
doc: &mut Doc,
slot: Slot<'_>,
path: &[Segment],
op: &EditOp,
cx: &mut ActionCx,
) -> Result<(), ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
Apply the field edit op at path, below the value in slot,
touching only what it changes, then run the invariants of the values
it touched. The default edits a value only as a whole.
Sourcefn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
The field edits that turn self into after, at path below the
record: what a surface that edited a local copy submits. The default
sets the value whole when it changed; containers and records edit
only what differs, item by item and field by field. A value that
would store as it is (Self::stores_as) is compared in memory,
without turning either side into JSON.
Sourcefn nested_collections(&self) -> Vec<ItemCollection>
fn nested_collections(&self) -> Vec<ItemCollection>
The item collections inside this value, when it is an item of a
collection itself (a slide’s elements); #[derive(Model)] lists a
record’s, the default has none.
Sourcefn value_schema() -> Value
fn value_schema() -> Value
The JSON Schema of this value’s JSON form (Self::to_json), as
the published field edit describes what a path takes; the default
accepts any value.
Sourcefn field_type(types: &mut TypeSet) -> FieldType
fn field_type(types: &mut TypeSet) -> FieldType
This value’s type in the language-neutral vocabulary a surface
publishes (FieldType), declaring the records
and enums it names in types. The default describes no type: any
value.
Sourcefn read_whole(&mut self, doc: &Doc) -> Result<(), ModelError>
fn read_whole(&mut self, doc: &Doc) -> Result<(), ModelError>
Read everything this value holds, for a field marked
#[model(whole)]: a value read lazily (rich text reads its
paragraphs as views ask for them) reads all of it, so every reader of
the record — a verb, search, read_content — sees all of it. The
default has nothing more to read.
§Errors
Returns ModelError when the document no longer holds the value.
Sourcefn check(&self) -> Result<(), Refusal>
fn check(&self) -> Result<(), Refusal>
Run every #[model(check)] invariant of this value and the values
inside it.
Sourcefn label(&self) -> Option<String>
fn label(&self) -> Option<String>
What names this value for people (#[model(label)]): history, search,
agents and item resources use it.
Sourcefn op_coalesces(
path: &[Segment],
previous: &Value,
next: &Value,
) -> Option<bool>
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
Whether two edits in the own vocabulary of the value at path below
this type are one gesture (Operations); None
when nothing there has one.
Sourcefn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
Whether a gesture may go on after the edit op at path.
Sourcefn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
What the edit op at path below this type did, in the history
entry’s terms (Operations::describe).
Sourcefn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
Where the actor of the edit op at path below this value is after
it applied.
Sourcefn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
The schemas of the own vocabularies of the values below this type,
by path pattern from prefix (* for every item).
Sourcefn get_at(&self, path: &[Segment]) -> Option<&dyn Any>where
Self: 'static,
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>where
Self: 'static,
The value at path below this one, if it is there. A value with
nothing inside it is found only at the empty path.
Sourcefn missing() -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
The value of an absent slot. Types with a natural empty value return it, so a field added to a schema reads older documents without migration.
§Errors
Returns ModelError::Missing for types without an empty value.
Sourcefn fresh(&self, encoding: TextEncoding) -> Fresh
fn fresh(&self, encoding: TextEncoding) -> Fresh
What store writes under a key of a map made just
now, for the map to be made with it at once; encoding is the
document’s text encoding. The default stores it once the map is made.
Sourcefn stores_as(&self, before: &Self) -> bool
fn stores_as(&self, before: &Self) -> bool
Whether writing self over a slot that holds before, as a
store left it, would change nothing: an in-memory
comparison, so an action that changed one item of a long collection
does not visit the others. Must only answer true when store would
write no operation; the default answers false (unknown).
Sourcefn store_changed(
&self,
before: &Self,
doc: &mut Doc,
slot: Slot<'_>,
dirty: &Delta,
) -> Result<(), ModelError>
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
Write self into slot, which holds before: exactly the operations
store would write, found by comparing with before
where store would read the document.
before is what load reads from the slot now, and the
slot is as a store left it except where dirty (changes written by
someone else since) says otherwise: a slot dirty touched is written
as store would. The default is store. An action’s write is
replayed on every replica, so an override that writes anything else
forks the document.
Sourcefn refresh(
&mut self,
doc: &Doc,
value: &Value<'_>,
id: &ObjId,
delta: &Delta,
) -> Result<(), ModelError>
fn refresh( &mut self, doc: &Doc, value: &Value<'_>, id: &ObjId, delta: &Delta, ) -> Result<(), ModelError>
Bring a value read earlier up to date after the changes in delta,
re-reading only what they touched. value and id are what the
parent’s slot holds now — the same object as when self was read, or
the parent would have read it anew. The default reads the value again,
which is right for scalars and short values.
§Errors
Returns ModelError when the stored value has another shape.
Sourcefn collect_text(&self, _out: &mut Vec<String>)
fn collect_text(&self, _out: &mut Vec<String>)
Append the human-readable text this value carries, for search indexing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Model for ()
Nothing: a value that stores nothing, for the members of a container that
only orders ids (a Grid’s rows and columns).
impl Model for ()
Nothing: a value that stores nothing, for the members of a container that
only orders ids (a Grid’s rows and columns).
Source§fn store(&self, _: &mut Doc, _: Slot<'_>) -> Result<(), ModelError>
fn store(&self, _: &mut Doc, _: Slot<'_>) -> Result<(), ModelError>
Nothing is written: an absent slot reads as () already.
const TABLE: &'static ModelTable
type Paths<R> = Path<R, ()>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(_: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, _: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
Source§impl Model for ActionParam
impl Model for ActionParam
const TABLE: &'static ModelTable
type Paths<R> = Path<R, ActionParam>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
fn check(&self) -> Result<(), Refusal>
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
fn refresh( &mut self, doc: &Doc, value: &Value<'_>, id: &ObjId, delta: &Delta, ) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
fn missing() -> Result<Self, ModelError>
Source§impl Model for Actor
impl Model for Actor
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Actor>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for AppId
impl Model for AppId
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, AppId>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for Date
impl Model for Date
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Date>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn field_type(types: &mut TypeSet) -> FieldType
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
Source§impl Model for DateTime
impl Model for DateTime
const TABLE: &'static ModelTable
type Paths<R> = Path<R, DateTime>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn field_type(types: &mut TypeSet) -> FieldType
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
Source§impl Model for Grantee
impl Model for Grantee
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Grantee>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for Lifetime
impl Model for Lifetime
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Lifetime>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for Map<String, Value>
impl Model for Map<String, Value>
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Map<String, Value>>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn value_schema() -> Value
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for String
impl Model for String
Source§fn fresh(&self, encoding: TextEncoding) -> Fresh
fn fresh(&self, encoding: TextEncoding) -> Fresh
Its text, made marked as its writer’s.
Source§fn store_changed(
&self,
before: &Self,
doc: &mut Doc,
slot: Slot<'_>,
_dirty: &Delta,
) -> Result<(), ModelError>
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, _dirty: &Delta, ) -> Result<(), ModelError>
The one splice store makes, found from before
instead of reading the whole text back.
const TABLE: &'static ModelTable
type Paths<R> = Path<R, String>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, _cx: &mut ActionCx, ) -> Result<(), ModelError>
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
fn collect_text(&self, out: &mut Vec<String>)
Source§impl Model for Time
impl Model for Time
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Time>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn field_type(types: &mut TypeSet) -> FieldType
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
Source§impl Model for Uuid
impl Model for Uuid
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Uuid>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for Value
impl Model for Value
Source§fn fresh(&self, _: TextEncoding) -> Fresh
fn fresh(&self, _: TextEncoding) -> Fresh
Made with the map as the maps, lists and scalars Self::store
writes.
const TABLE: &'static ModelTable
const NULLABLE: bool = true
type Paths<R> = Path<R, Value>
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for bool
impl Model for bool
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, bool>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for f32
impl Model for f32
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, f32>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, encoding: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for f64
impl Model for f64
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, f64>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for i8
impl Model for i8
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, i8>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for i16
impl Model for i16
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, i16>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for i32
impl Model for i32
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, i32>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for i64
impl Model for i64
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, i64>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for isize
impl Model for isize
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, isize>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for u8
impl Model for u8
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, u8>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for u16
impl Model for u16
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, u16>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for u32
impl Model for u32
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, u32>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for u64
impl Model for u64
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, u64>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl Model for usize
impl Model for usize
const SCALAR: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, usize>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(_: &Doc, value: &Value<'_>, _: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn fresh(&self, _: TextEncoding) -> Fresh
fn stores_as(&self, before: &Self) -> bool
Source§impl<T: Model, const N: usize> Model for [T; N]
impl<T: Model, const N: usize> Model for [T; N]
const CHECKS: bool = T::CHECKS
const OPS: bool = T::OPS
type Paths<R> = Path<R, [T; N]>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
Source§impl<T: Model> Model for BTreeMap<String, T>
impl<T: Model> Model for BTreeMap<String, T>
const SHAPE: Shape
const CHECKS: bool = T::CHECKS
const OPS: bool = T::OPS
const TABLE: &'static ModelTable
type Paths<R> = Path<R, BTreeMap<String, T>>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
fn check(&self) -> Result<(), Refusal>
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
fn refresh( &mut self, doc: &Doc, value: &Value<'_>, id: &ObjId, delta: &Delta, ) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
fn missing() -> Result<Self, ModelError>
Source§impl<T: Model> Model for Box<T>
impl<T: Model> Model for Box<T>
const SCALAR: bool = T::SCALAR
const SHAPE: Shape = T::SHAPE
const CHECKS: bool = T::CHECKS
const OPS: bool = T::OPS
const NULLABLE: bool = T::NULLABLE
type Paths<R> = <T as Model>::Paths<R>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn paths_at<R>(path: Path<R, Self>) -> T::Paths<R>
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
fn check(&self) -> Result<(), Refusal>
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
fn label(&self) -> Option<String>
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>where
Self: 'static,
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn missing() -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
fn refresh( &mut self, doc: &Doc, value: &Value<'_>, id: &ObjId, delta: &Delta, ) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
Source§impl<T: Model> Model for Option<T>
impl<T: Model> Model for Option<T>
const SHAPE: Shape = T::SHAPE
const CHECKS: bool = T::CHECKS
const OPS: bool = T::OPS
const NULLABLE: bool = true
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Option<T>>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
fn check(&self) -> Result<(), Refusal>
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
fn refresh( &mut self, doc: &Doc, value: &Value<'_>, id: &ObjId, delta: &Delta, ) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
fn label(&self) -> Option<String>
fn missing() -> Result<Self, ModelError>
Source§impl<T: Model> Model for Vec<T>
impl<T: Model> Model for Vec<T>
const CHECKS: bool = T::CHECKS
const OPS: bool = T::OPS
const TABLE: &'static ModelTable
type Paths<R> = Path<R, Vec<T>>
fn value_schema() -> Value
fn field_type(types: &mut TypeSet) -> FieldType
fn paths_at<R>(path: Path<R, Self>) -> Path<R, Self>
fn op_coalesces( path: &[Segment], previous: &Value, next: &Value, ) -> Option<bool>
fn op_continuable(path: &[Segment], op: &Value) -> Option<bool>
fn op_describe(path: &[Segment], op: &Value) -> Option<OpDescription>
fn op_lands(&self, path: &[Segment], op: &Value) -> Option<Place>
fn op_schemas(prefix: &str, out: &mut Vec<(String, Value)>)
fn to_json(&self) -> Value
fn from_json(value: &Value) -> Result<Self, ModelError>
fn edit( doc: &mut Doc, slot: Slot<'_>, path: &[Segment], op: &EditOp, cx: &mut ActionCx, ) -> Result<(), ModelError>
fn check(&self) -> Result<(), Refusal>
fn get_at(&self, path: &[Segment]) -> Option<&dyn Any>
fn diff<R>(&self, after: &Self, path: &[Segment], out: &mut Vec<Edit<R>>)
fn load(doc: &Doc, value: &Value<'_>, id: &ObjId) -> Result<Self, ModelError>
fn store(&self, doc: &mut Doc, slot: Slot<'_>) -> Result<(), ModelError>
fn stores_as(&self, before: &Self) -> bool
fn store_changed( &self, before: &Self, doc: &mut Doc, slot: Slot<'_>, dirty: &Delta, ) -> Result<(), ModelError>
fn refresh( &mut self, doc: &Doc, value: &Value<'_>, id: &ObjId, delta: &Delta, ) -> Result<(), ModelError>
fn collect_text(&self, out: &mut Vec<String>)
fn missing() -> Result<Self, ModelError>
Implementors§
Source§impl<O: Serialize + DeserializeOwned + Default + 'static> Model for Settled<O>
A settlement stores as one JSON value: it is written once, by the owning
device.
impl<O: Serialize + DeserializeOwned + Default + 'static> Model for Settled<O>
A settlement stores as one JSON value: it is written once, by the owning device.