Skip to main content

Context

Struct Context 

Source
pub struct Context {
    program: &'static ProgramDesc,
    states: Box<[Cell<Slot>]>,
    changed: RefCell<StateSet>,
    call_depth: Cell<usize>,
    failed: RefCell<Option<(Failure, u32)>>,
    downloads: RefCell<Vec<Request<Targets>>>,
    download_commands: RefCell<Vec<(DownloadCommand, String)>>,
    dialogs: RefCell<Vec<(FileDialog, Answer)>>,
    window_requests: RefCell<Vec<WindowRequest>>,
}
Expand description

Compiled code receives this as an opaque pointer and passes it back on every call.

Fields§

§program: &'static ProgramDesc§states: Box<[Cell<Slot>]>§changed: RefCell<StateSet>

States changed since the UI last caught up.

§call_depth: Cell<usize>§failed: RefCell<Option<(Failure, u32)>>

Why the code that just returned false failed, and the span id of where.

§downloads: RefCell<Vec<Request<Targets>>>

Downloads asked for since the app last started them.

§download_commands: RefCell<Vec<(DownloadCommand, String)>>

What code asked of running downloads since the app last passed it on.

§dialogs: RefCell<Vec<(FileDialog, Answer)>>

File dialogs asked for since the app last passed them on.

§window_requests: RefCell<Vec<WindowRequest>>

Windows asked to open or close since the app last passed them on.

Implementations§

Source§

impl Context

Source

pub(crate) fn new(program: &'static ProgramDesc) -> Result<Self, AppError>

Sets every state to its starting value, in order, so each may read the ones before.

Source

pub(crate) fn state(&self, state: usize) -> Slot

Source

pub(crate) fn state_mut(&self, state: usize) -> *mut Slot

The slot of state, which is marked changed since the caller is about to write it.

Source

pub(crate) fn take_changed(&self) -> StateSet

Source

pub(crate) fn fail(&self, failure: Failure, span: u32)

Source

pub(crate) fn enter(&self, function: u32, span: u32) -> bool

Counts a call into function, or fails when calls are too deep.

Source

pub(crate) fn leave(&self)

Source

pub(crate) fn request_download(&self, request: Request<Targets>)

Source

pub(crate) fn take_downloads(&self) -> Vec<Request<Targets>>

The downloads asked for since the last call.

Source

pub(crate) fn request_download_command( &self, command: DownloadCommand, id: String, )

Source

pub(crate) fn take_download_commands(&self) -> Vec<(DownloadCommand, String)>

What code asked of running downloads since the last call, in order, by their ids.

Source

pub(crate) fn ask_dialog(&self, dialog: FileDialog, answer: Answer)

Source

pub(crate) fn request_window(&self, request: WindowRequest)

Source

pub(crate) fn take_window_requests(&self) -> Vec<WindowRequest>

The windows asked to open or close since the last call, in order.

Source

pub(crate) fn take_dialogs(&self) -> Vec<(FileDialog, Answer)>

The file dialogs asked for since the last call.

Source

pub(crate) fn take_error(&self) -> AppError

Why compiled code just returned false, which it does only after a runtime call recorded a failure.

§Panics

When no failure was recorded, which only wrongly compiled code does.

Source

pub(crate) fn error(&self, failure: &Failure, span: u32) -> AppError

Source

fn location(&self, span: u32) -> Option<SourceLocation>

Source§

impl Context

Source

pub(crate) fn answer_dialog( &self, answer: &Answer, picked: Picked, ) -> Result<(), AppError>

Writes the path or paths the user picked into the state the dialog’s call bound; cancelling changes nothing.

Source§

impl Context

Source

pub(crate) fn report_download( &self, targets: &Targets, report: &Report, ) -> Result<(), AppError>

Writes a download’s report into the state its call bound.

Source

pub(crate) fn follow_download(&self, targets: &mut Targets) -> bool

Moves a download’s targets to where the item holding its id is now; false when nothing holds it any more.

Source

fn write_report( &self, targets: &Targets, report: &Report, ) -> Result<(), Failure>

Source§

impl Context

Source

fn read_location(&self, location: &Location) -> Option<Slot>

The value at location, borrowed; None once a list position on the way is gone.

Source

pub(crate) fn write_location( &self, location: &Location, value: Slot, ty: &TypeDesc, ) -> Result<(), Failure>

Replaces the value at location with value, of type ty, which it takes ownership of, and marks its state changed.

Trait Implementations§

Source§

impl Debug for Context

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> AutoreleaseSafe for T
where T: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.