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
impl Context
Sourcepub(crate) fn new(program: &'static ProgramDesc) -> Result<Self, AppError>
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.
pub(crate) fn state(&self, state: usize) -> Slot
Sourcepub(crate) fn state_mut(&self, state: usize) -> *mut Slot
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.
pub(crate) fn take_changed(&self) -> StateSet
pub(crate) fn fail(&self, failure: Failure, span: u32)
Sourcepub(crate) fn enter(&self, function: u32, span: u32) -> bool
pub(crate) fn enter(&self, function: u32, span: u32) -> bool
Counts a call into function, or fails when calls are too deep.
pub(crate) fn leave(&self)
pub(crate) fn request_download(&self, request: Request<Targets>)
Sourcepub(crate) fn take_downloads(&self) -> Vec<Request<Targets>>
pub(crate) fn take_downloads(&self) -> Vec<Request<Targets>>
The downloads asked for since the last call.
pub(crate) fn request_download_command( &self, command: DownloadCommand, id: String, )
Sourcepub(crate) fn take_download_commands(&self) -> Vec<(DownloadCommand, String)>
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.
pub(crate) fn ask_dialog(&self, dialog: FileDialog, answer: Answer)
pub(crate) fn request_window(&self, request: WindowRequest)
Sourcepub(crate) fn take_window_requests(&self) -> Vec<WindowRequest>
pub(crate) fn take_window_requests(&self) -> Vec<WindowRequest>
The windows asked to open or close since the last call, in order.
Sourcepub(crate) fn take_dialogs(&self) -> Vec<(FileDialog, Answer)>
pub(crate) fn take_dialogs(&self) -> Vec<(FileDialog, Answer)>
The file dialogs asked for since the last call.
Sourcepub(crate) fn take_error(&self) -> AppError
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.
pub(crate) fn error(&self, failure: &Failure, span: u32) -> AppError
fn location(&self, span: u32) -> Option<SourceLocation>
Source§impl Context
impl Context
Sourcepub(crate) fn report_download(
&self,
targets: &Targets,
report: &Report,
) -> Result<(), AppError>
pub(crate) fn report_download( &self, targets: &Targets, report: &Report, ) -> Result<(), AppError>
Writes a download’s report into the state its call bound.
Sourcepub(crate) fn follow_download(&self, targets: &mut Targets) -> bool
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.