Expand description
The model of a business application, with no GUI: entities, a layered application model, object spaces, actions, controllers, frames and modules.
use ravenrs_app::{EntityInfo, FieldInfo, FieldKind, MemoryDatabase, ModelLayers, ModelLayer, ObjectSpace, generate_model};
let account = EntityInfo::new("Account")
.caption("Conta")
.navigation("Cadastros")
.field(FieldInfo::new("id", FieldKind::Integer).key())
.field(FieldInfo::new("name", FieldKind::Text).caption("Nome").default_property());
// The model: a list, a form and a place in the navigation, changed by a layer.
let mut layers = ModelLayers::new(generate_model(std::slice::from_ref(&account))?);
layers.set(&ModelLayer::User, &["NavigationItems", "Cadastros"], "Caption", "Registros".into());
let model = layers.merged();
assert_eq!(model.root.at(&["NavigationItems", "Cadastros"]).and_then(|n| n.text("Caption")), Some("Registros"));
// The records: nothing is kept until the commit.
let mut space = MemoryDatabase::new(vec![account])?.space();
let mut object = space.new_object("Account")?;
object.set("name", "Corrente");
space.save(object)?;
assert!(space.is_modified());
space.commit()?;Structs§
- Action
- Something people can do. A handle: the frame and its controller hold the same action, so a controller can turn it off by a reason of its own.
- Action
Context - What an action sees while running. A copy is the same run: what it asks for next counts.
- Appearance
- What the rules that apply come to.
- Appearance
Rule - Changes how things look or behave, for records that meet a condition. It is about looks: it does not protect data, which is what permissions are for.
- Application
- An application put together: its entities, its model and what makes frames. Layers from
the administrator and the user go on with
layers_mut. - Application
Builder - Collects what goes in an
Application. - Audit
Settings - What the audit trail covers.
- Audit
Trail - What the audit trail needs: what it covers, who is acting, and what to add to the next commit.
- Audited
Object Space - A unit of work that writes what it commits to the audit trail, in the same commit, so a change and its trail stay or go together. Changes made to the database some other way are not seen.
- Change
Set - What a unit of work has waiting, for whoever implements one: new, changed and deleted records, one change per record.
- Choice
Item - One option of a single-choice action, which can hold others.
- Credentials
- What someone gave to sign in.
- Dashboard
Info - Other views together. It is bound to no records: each piece keeps its own frame.
- Dashboard
Item - A piece of a dashboard.
- Diff
- A difference over the layers below it, as JSON: an object is a node, by id, and anything else is a setting.
- Embedded
Store - A difference that came inside the program, as a module’s does. It cannot change.
- Entity
Info - A kind of record.
- Enum
Option - One of the values of a
FieldKind::Enum. - Field
Info - A field of an
EntityInfo. - File
Storage - Pieces of data kept as files in a folder on the desktop, one file per name. A write goes to a draft first and then takes the file’s place, so a crash never leaves half a file.
- File
Store - A difference in a file. A failure while saving leaves the old file whole.
- Frame
- Where a view lives: it holds the view, the controllers that fit it, their actions and a unit of work. A handle, so controllers and actions can keep one.
- Identity
- Who is using the application.
- Job
- A job that started, as the screen sees it. A handle: the frame keeps one while it runs.
- JobContext
- What a job sees while it runs, on its own thread.
- List
Filter - A filter ready for people to pick from a menu on a list.
- Memory
Attachment Store - Files that last as long as the program, as on the web with no server.
- Memory
Database - Records kept in memory, on desktop and in the browser. Any number of spaces share them, and each sees what the others committed.
- Memory
Model Store - A difference that lasts as long as the program, where nothing else is at hand.
- Memory
Object Space - A unit of work over a
MemoryDatabase. - Memory
Storage - Pieces of data kept in memory, gone when the program ends: for tests and previews.
- Merged
- What comes of putting together what a person changed and what someone else kept meanwhile.
- Merged
Model - The model as it stands, with all its layers applied.
- Message
- Something to tell people, which goes away by itself.
- Model
Error - Something wrong in how the application was declared, in words for its developer.
- Model
Layers - The generated model and the layers over it. Taking a setting off a layer brings back what the layer below says.
- Model
Node - A node of the application model: an id, settings and nodes under it.
- Object
- A record: its entity’s name and a value per field. Dynamic, so filters, rules and permissions read every entity the same way.
- Permissions
- What one person can do: the answers of their roles, brought together.
- Query
- What to read: a filter, an order and a page.
- Reasons
- Why something is on or off: pairs of reason and answer. It is on only if every answer is yes, so one part of the application turning it off cannot be undone by another.
- Record
Action - An action of an entity that sets fields of the records selected.
- Reminder
- The field of a record that says when to remind people of it, and what to say.
- Role
- A set of permissions a person can have.
- Rule
- One thing a record has to meet, in some contexts, and perhaps only when it fits.
- Rule
Words - The words of what fails, where
{0}is the name of the field. - Secured
Object Space - A unit of work that only does what the person signed in can do, whoever asks: a screen, an action or a call with no screen around it.
- Security
Context - Who is signed in and what the security system needs to answer for them. One per signed-in person, shared by their units of work.
- State
Machine - The states of a record, in one of its fields, and the ways between them.
- Stored
Model - The person’s own settings kept in a
Storageunder a name: a file on the desktop, the browser’s IndexedDB on the web, beside the records. - Target
Scope - Which views an action or a controller is for. Anything left out does not narrow it.
- Transition
- A way from one state to another.
- Unusable
Node - A part of a difference that has no node to land on, as after the entity it refers to is gone. It is kept, and comes back into use if the node does.
- User
Directory - The people who can sign in, kept as records.
- View
Info - A view, as the model describes it.
- View
Variant - Another way to see the list of an entity, which people pick from a menu once there are two.
- Violation
- A rule that was not met.
Enums§
- Access
- What a permission says.
- Action
Category - Where an action belongs, which decides the place it shows in.
- Action
Error - Why an action did not run.
- Action
Input - What people gave an action that asks for something.
- Action
Kind - How an action asks for what it needs.
- Action
Result - What the running of an action asks for next, by whoever shows the application.
- Appearance
Context - Which views a rule applies in.
- Appearance
Target - What a rule changes the look of.
- Audit
Mode - How much is written about the records of an entity.
- Auth
Error - Why someone could not sign in.
- Change
- A change waiting for a commit.
- Comparison
- How a
RuleKind::Comparecompares. - Criteria
- A parsed expression or filter.
- Criteria
Mode - How
Action::target_criteriacounts the selected records. - Dashboard
Content - What a piece of a dashboard shows.
- Data
Access - How a list gets its records.
- Field
Kind - What a field holds, which decides how it is edited and stored.
- Frame
Context - Where a frame is, which decides its template and what targets it.
- Frame
Event - What a frame goes through, in order, for whoever shows it.
- JobChange
- A change a job hands back, kept by the frame on the screen’s thread.
- Message
Kind - How much a
Messagematters. - Model
Layer - A layer of the model, from the lowest to the highest. The highest to set a value wins.
- Nesting
- Whether views inside others count.
- Operand
- What a
RuleKind::Comparecompares with. - Operation
- What can be done to a record.
- Password
Error - Why a password could not be set.
- Permission
Policy - What a role says about what no permission mentions.
- Role
Merge - How the answers of several roles of one person come together.
- Rule
Kind - What a
Ruleasks for. - Selection
- What an action needs selected to be enabled.
- Severity
- How much not meeting a rule matters.
- Space
Error - Why a space could not do what it was asked.
- Space
Event - What happens to a space, for whoever watches it.
- Text
Comparison - How a
RuleKind::Textcompares. - Tint
- A color with a meaning, which every theme has its own version of.
- Value
- A value: what fields hold and expressions compute.
- View
Kind - What a view shows.
Constants§
- ADMINISTRATORS_
ROLE - The role the first person gets.
- CONTEXT_
DELETE - The context of taking a record away.
- CONTEXT_
SAVE - The context of keeping a record. Rules are in it unless they say otherwise.
- MIN_
PASSWORD_ CHARS - The shortest password taken, in characters.
- REASON_
APPEARANCE - The reason an action is off because of an appearance rule.
- REASON_
CONTROLLER - The reason an action is off because its controller is.
- REASON_
CRITERIA - The reason an action is off because the selected records do not meet its criteria.
- REASON_
RUNNING - Off while its work runs away from the screen.
- REASON_
SCOPE - The reason an action or a controller is off because its view is not the one it targets.
- REASON_
SECURITY - The reason permissions turned an action off.
- REASON_
SELECTION - The reason an action is off because of what is selected.
- SECURITY_
ACTION_ PERMISSION - What a role says about an action.
- SECURITY_
AUDIT_ ENTRY - The entity of the audit trail.
- SECURITY_
MEMBER_ PERMISSION - What a role says about fields.
- SECURITY_
NAVIGATION_ PERMISSION - What a role says about a navigation item.
- SECURITY_
OBJECT_ PERMISSION - What a role says about the records an expression holds for.
- SECURITY_
ROLE - The entity of roles.
- SECURITY_
TYPE_ PERMISSION - What a role says about a whole entity.
- SECURITY_
USER - The entity of the people who can sign in.
- SECURITY_
USER_ ROLE - The entity that says who has which role.
Traits§
- Attachment
Store - Keeps the content of files, and gives a key for each. A record holds only that key, so reading a list does not read every file.
- Authenticator
- A way of signing in. Passwords are
UserDirectory; a way that talks to an outside provider, as OAuth 2 does, implements this and asksUserDirectory::identity_offor the roles. - Business
Object - A record as a Rust struct. Derive it:
- Field
Value - A Rust type a field can have.
- Model
Store - Keeps one layer’s difference.
- Module
- A part of an application: what it adds, in one place. Modules stack, each over those it depends on.
- Object
Space - A unit of work over records: what it reads includes its own changes, and nothing
reaches storage until
commit. A view has one of these, so canceling a form throws away only that form’s changes. - Object
Space Ext - Reading and writing with Rust structs, on any object space.
- Storage
- Named pieces of data kept between runs.
- View
Controller - Behavior tied to a view: it turns on when a view it targets is shown, and off when that goes. Its actions are off while it is off. Each frame has its own.
- Window
Controller - Behavior tied to a window, whatever view it shows. Stays on while the frame lasts.
Functions§
- audit_
entity - The entity of the audit trail, which storage has to know when there is one.
- check_
model - What in a model points to nothing, in words for whoever changed it: a view of an entity that is gone, a column of a field that is not there, a menu item with no view.
- check_
query - Says whether a query fits an entity.
- check_
transitions - Whether a change keeps to the state machines of its entity. Whoever keeps records calls this with what is stored and what is about to be, before writing, as every space here does.
- environment
- What an expression is evaluated with: the language and what was added to it.
- generate_
model - The model the entities give: their members, a list, a list to pick from and a form for each, and the navigation.
- hash_
password - What is kept for a password: Argon2id, with its parameters and a salt of its own, in the usual text form. A new v4 UUID is 122 random bits from the system.
- key_of
- The key of a record, as text.
- key_
text - A key as text, the same for equal keys.
- live_
expose - Registers this crate’s types with a playground’s interpreter (feature
live). - local_
now - The date and time on this machine, as people read it on a clock.
- merge_
changes - Puts together what a person changed, from
originaltomine, and what isstorednow. Changes to different fields both stand, so only changing the same field takes a decision. - register_
function - Adds a function to expressions in rules, appearance, actions, calculated fields and filters. An application’s state is of one thread, and so is this. A filter with one runs in memory, as the database does not know it.
- reminders_
of - The records of an entity with a reminder that have a time set, for this person, as this space shows them. What is due by now is up to whoever asks, as they know the time.
- run_
query - Runs a query over records in memory: computes, filters, sorts and takes the page.
- security_
entities - The entities of users, roles and permissions, which storage has to know.
- validate
- Checks a record against the rules of its entity that apply in this context. It does not run by itself: forms call it before keeping, and anything else that writes calls it itself.
- validate_
in_ place - The same, leaving out rules that have to read other records, for checking every row of a list.
- verify_
password - Whether this password is the one this was made from. Something unreadable matches nothing.
Type Aliases§
- JobWaker
- Something that wakes the screen, from any thread.
- JobWork
- What a background action does: it reads what it was given, does its work and tells as it goes. An error ends it, in words for people.
- Space
Maker - Makes a unit of work with no permissions around it. It only ever goes to what needs to read before anyone has signed in, or to what the security system does itself.
- Space
Watcher - Watches a space; see
ObjectSpace::on_event.
Derive Macros§
- Business
Enum - Declares an enum with no data as the options of a field:
#[option(caption = "...", code = "...")]on a variant. The first variant is what a new record starts with. - Business
Object - Declares a struct as a business object: an entity for the model, and the way to and from a record.