Skip to main content

Crate ravenrs_app

Crate ravenrs_app 

Source
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.
ActionContext
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.
AppearanceRule
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.
ApplicationBuilder
Collects what goes in an Application.
AuditSettings
What the audit trail covers.
AuditTrail
What the audit trail needs: what it covers, who is acting, and what to add to the next commit.
AuditedObjectSpace
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.
ChangeSet
What a unit of work has waiting, for whoever implements one: new, changed and deleted records, one change per record.
ChoiceItem
One option of a single-choice action, which can hold others.
Credentials
What someone gave to sign in.
DashboardInfo
Other views together. It is bound to no records: each piece keeps its own frame.
DashboardItem
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.
EmbeddedStore
A difference that came inside the program, as a module’s does. It cannot change.
EntityInfo
A kind of record.
EnumOption
One of the values of a FieldKind::Enum.
FieldInfo
A field of an EntityInfo.
FileStorage
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.
FileStore
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.
ListFilter
A filter ready for people to pick from a menu on a list.
MemoryAttachmentStore
Files that last as long as the program, as on the web with no server.
MemoryDatabase
Records kept in memory, on desktop and in the browser. Any number of spaces share them, and each sees what the others committed.
MemoryModelStore
A difference that lasts as long as the program, where nothing else is at hand.
MemoryObjectSpace
A unit of work over a MemoryDatabase.
MemoryStorage
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.
MergedModel
The model as it stands, with all its layers applied.
Message
Something to tell people, which goes away by itself.
ModelError
Something wrong in how the application was declared, in words for its developer.
ModelLayers
The generated model and the layers over it. Taking a setting off a layer brings back what the layer below says.
ModelNode
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.
RecordAction
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.
RuleWords
The words of what fails, where {0} is the name of the field.
SecuredObjectSpace
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.
SecurityContext
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.
StateMachine
The states of a record, in one of its fields, and the ways between them.
StoredModel
The person’s own settings kept in a Storage under a name: a file on the desktop, the browser’s IndexedDB on the web, beside the records.
TargetScope
Which views an action or a controller is for. Anything left out does not narrow it.
Transition
A way from one state to another.
UnusableNode
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.
UserDirectory
The people who can sign in, kept as records.
ViewInfo
A view, as the model describes it.
ViewVariant
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.
ActionCategory
Where an action belongs, which decides the place it shows in.
ActionError
Why an action did not run.
ActionInput
What people gave an action that asks for something.
ActionKind
How an action asks for what it needs.
ActionResult
What the running of an action asks for next, by whoever shows the application.
AppearanceContext
Which views a rule applies in.
AppearanceTarget
What a rule changes the look of.
AuditMode
How much is written about the records of an entity.
AuthError
Why someone could not sign in.
Change
A change waiting for a commit.
Comparison
How a RuleKind::Compare compares.
Criteria
A parsed expression or filter.
CriteriaMode
How Action::target_criteria counts the selected records.
DashboardContent
What a piece of a dashboard shows.
DataAccess
How a list gets its records.
FieldKind
What a field holds, which decides how it is edited and stored.
FrameContext
Where a frame is, which decides its template and what targets it.
FrameEvent
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.
MessageKind
How much a Message matters.
ModelLayer
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::Compare compares with.
Operation
What can be done to a record.
PasswordError
Why a password could not be set.
PermissionPolicy
What a role says about what no permission mentions.
RoleMerge
How the answers of several roles of one person come together.
RuleKind
What a Rule asks for.
Selection
What an action needs selected to be enabled.
Severity
How much not meeting a rule matters.
SpaceError
Why a space could not do what it was asked.
SpaceEvent
What happens to a space, for whoever watches it.
TextComparison
How a RuleKind::Text compares.
Tint
A color with a meaning, which every theme has its own version of.
Value
A value: what fields hold and expressions compute.
ViewKind
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§

AttachmentStore
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 asks UserDirectory::identity_of for the roles.
BusinessObject
A record as a Rust struct. Derive it:
FieldValue
A Rust type a field can have.
ModelStore
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.
ObjectSpace
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.
ObjectSpaceExt
Reading and writing with Rust structs, on any object space.
Storage
Named pieces of data kept between runs.
ViewController
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.
WindowController
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 original to mine, and what is stored now. 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.
SpaceMaker
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.
SpaceWatcher
Watches a space; see ObjectSpace::on_event.

Derive Macros§

BusinessEnum
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.
BusinessObject
Declares a struct as a business object: an entity for the model, and the way to and from a record.