Skip to main content

state_from_reading

Function state_from_reading 

pub fn state_from_reading<R>(
    reading: &Value,
) -> Result<<R as Resource>::State, ModelError>
where R: Resource,
Expand description

A record’s state from the reading a document host publishes for it (Resource::state_json, crate::Model::to_json): what an app’s process reads when the record lives in the session’s document host and it holds no document of its own (docs/architecture/apps.md §2–§3).

The host answers the reading, and the app’s own view reads its fields through its own model types: the state a reading names is the state the host read from its document, so what the view shows is what the host holds.

§Errors

Returns [ModelError] when the type keeps no JSON form (Resource::RECORD_TABLE is None) or reading is not one of it.