Skip to main content

Session

Struct Session 

Source
pub struct Session(/* private fields */);
Expand description

What the screens of a running application share: the frame, the current form, and what has to happen next. A handle.

Implementations§

Source§

impl Session

Source

pub fn list_records(&self, view: &ViewInfo) -> Vec<Object>

The records of a list, the way it chose to see them, as this person can read them.

Source

pub fn list_table(&self, view: &ViewInfo) -> Option<GridTable>

A list as it stands: the columns showing and every record the way it chose to see them, as a table to make a report or a file from.

Source§

impl Session

Source

pub fn embedded<S: ObjectSpace + 'static>( application: Application, space: impl Fn() -> S + 'static, words: Words, ) -> Self

A session for lists and actions inside a screen an application made itself, with no window around them. Showing a view is up to it, with show_list.

Source

pub fn show_list(&self, id: &str)

Shows this view of the model in the frame, without asking anything.

Source

pub fn confirmations(&self) -> ConfirmDialog

What asks before actions run, for a screen with no window of the framework around it.

Source

pub fn toaster(&self) -> Toaster

What shows messages, for a screen with no window of the framework around it.

Source

pub fn show_message(&self, message: Message)

Tells people something, which goes away by itself.

Source

pub fn use_records( &self, entity: impl Into<String>, source: impl Fn() -> Vec<Object> + 'static, )

Gives the records of an entity no storage keeps, for its list and its forms.

Source

pub fn use_collection( &self, entity: impl Into<String>, field: impl Into<String>, source: impl Fn(&Object) -> Vec<Object> + 'static, )

Gives the records of a list no storage keeps, inside a form of this entity.

Source

pub fn export_captions(&self) -> String

What people see in the model, as CSV with an empty column for its translation.

Source

pub fn import_captions(&self, language: &str, csv: &str) -> Result<(), String>

Takes the CSV of export_captions, filled in, as the model in this language, which set_language picks.

Source

pub fn register_control( &self, name: impl Into<String>, control: impl Fn() -> AnyView + 'static, )

Registers a control by name, for a dashboard to show.

Source

pub fn set_model_setting( &self, path: &[&str], name: &str, value: &str, ) -> Result<(), String>

Changes a setting of the model in the person’s own layer, if they may, and keeps it.

Source

pub fn restore_model_settings(&self) -> Result<(), String>

Throws away the person’s own changes to the model, if they may.

Source

pub fn show_full(&self, content: impl Fn() -> AnyView + 'static)

Shows this in place of the view, with the navigation still around it, until close_full or going anywhere else.

Source

pub fn close_full(&self)

Goes back to the view from what show_full showed.

Source

pub fn close_presented(&self)

Closes what present showed.

Source

pub fn present( &self, title: impl Into<String>, content: impl Fn() -> AnyView + 'static, )

Shows this in a window over the screens, until it is closed.

Source

pub fn set_form_caption(&self, caption: FormCaption)

Says what a field of a form is called when that depends on the record.

Source

pub fn form_record(&self) -> Option<Object>

The record on the form as it stands, following its fields.

Source

pub fn use_model_store(&self, store: Rc<dyn ModelStore>) -> Result<(), String>

Keeps the person’s own layer of the model there, and reads what is there now.

Source

pub fn set_language(&self, language: &str) -> Result<(), String>

Shows the model in this language, from the translations given.

Source

pub fn register_list_editor( &self, name: impl Into<String>, editor: impl Fn(&ListEditorRequest) -> AnyView + 'static, )

Registers how a list can be shown, for a view’s EditorType in the model to pick by name, or DefaultListEditor on Views for all of them.

Source

pub fn choose_list_editor(&self, view: &str, editor: &str) -> Result<(), String>

Shows this list with the editor of this name, which stays in the person’s own layer.

Source

pub fn use_attachment_store(&self, store: Rc<dyn AttachmentStore>)

Keeps the content of attached files there, apart from the records. Without it, a file stays inside its record’s field.

Source

pub fn user_settings(&self) -> Option<String>

What the person changed in the model, to keep between runs.

Source

pub fn set_form_value(&self, field: &str, value: Value)

Changes a field of the form, as a screen of its own around the form would.

Source

pub fn of(cx: &ActionContext) -> Option<Self>

The session an action is running in.

Source

pub fn of_frame(frame: &Frame) -> Option<Self>

The session of a frame.

Source

pub fn frame(&self) -> Frame

The main frame.

Source

pub fn words(&self) -> &Words

The words of the screens.

Source

pub fn texts(&self) -> Texts

Every text of the application in its language, with what it added over the ones that come with the framework, for words of its own by key.

Source

pub fn use_texts(&self, texts: Texts)

The texts texts gives, for this session and the ones inside it.

Source

pub fn model(&self) -> Rc<ModelNode>

The model as it stands.

Source

pub fn records_changed(&self)

Tells lists to read again, after something changed the records from outside.

Source

pub fn title(&self) -> String

The title of the application.

Source

pub fn entity(&self, name: &str) -> Option<EntityInfo>

An entity by name.

Source

pub fn announcer(&self) -> &Announcer

Where screen readers hear what changed: saving, deleting, the screen that opened. Its region is in the window; an application says more with it.

Source

pub fn set_access_words(&self, words: AccessWords)

The words of what screen readers hear, from the language of the application unless given.

Source

pub fn access_words(&self) -> AccessWords

The words of what screen readers hear.

Source

pub fn revision(&self) -> u64

Goes up whenever records may have changed; reading it builds again when they do.

Source

pub fn violations_of(&self, record: &Object, context: &str) -> Vec<Violation>

What this record fails in this context.

Source

pub fn error(&self) -> Option<String>

What went wrong last, in words for people.

Source

pub fn hand_file(&self, name: String, bytes: Vec<u8>, picker: &FilePicker)

Hands a file over to whoever asked for them, or else to the person.

Source

pub fn has_unsaved_changes(&self) -> bool

Whether there is a form with changes that were not kept.

Source

pub fn open_view(&self, id: &str)

Shows a list, asking first if that would lose changes.

Source

pub fn open_detail(&self, entity_name: &str, key: &Value)

Opens the form of a record, in a unit of work of its own.

Source

pub fn open_new(&self, entity_name: &str)

Opens the form of a new record.

Source

pub fn run_action(&self, action: &Action, input: ActionInput)

Runs an action from a screen: asks its question first, and does what it asks for next.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more