Docs / ArchitectureKit / Rust / Guides / Loading States

Loading States

Some queries need the state of a single subject rather than a view across many, and can read it the same way a command does.

To read the state of a single subject without executing a command, for example to answer a query about it, call the load function of the store with the subject, and name the state as the type of the result:

use architecturekit::Subject;

let book: Book = store.load(&Subject::new("/books/42")).await?;

load reads the events exactly the way execute does before it decides, including from_latest and the state cache. For a query across many subjects, use a view instead (see Defining Views).