pub struct Context<'a> {
pub device: &'a mut dyn Device,
pub errors: &'a mut dyn ErrorQueue,
pub esr: u8,
pub ese: u8,
pub sre: u8,
pub operation: EventRegister,
pub questionable: EventRegister,
/* private fields */
}
Expand description
Context in which to execute a message.
Contains registers related to the context and reference to the writer to respond with. Also contains a reference to the Device (may be shared by multiple contexts (Note! If threadsafe)).
Fields
device: &'a mut dyn Device
Device executed upon
errors: &'a mut dyn ErrorQueue
Error queue
esr: u8
Event Status Register
ese: u8
Event Status Enable register
sre: u8
Service Request Enable register
operation: EventRegister
OPERation:ENABle register
questionable: EventRegister
QUEStionable:ENABle register
Implementations
sourceimpl<'a> Context<'a>
impl<'a> Context<'a>
sourcepub fn new(
device: &'a mut dyn Device,
errorqueue: &'a mut dyn ErrorQueue,
root: &'a Node<'a>
) -> Self
pub fn new(
device: &'a mut dyn Device,
errorqueue: &'a mut dyn ErrorQueue,
root: &'a Node<'a>
) -> Self
Create a new context
Arguments
device
- Device to act uponwriter
- Writer used to write back response messagesroot
- SCPI command tree to use
sourcepub fn push_error(&mut self, err: Error)
pub fn push_error(&mut self, err: Error)
Put an error into the queue and set corresponding ESR bits
sourcepub fn exec<FMT>(
&mut self,
tokenstream: &mut Tokenizer<'_>,
response: &mut FMT
) -> Result<()> where
FMT: Formatter,
pub fn exec<FMT>(
&mut self,
tokenstream: &mut Tokenizer<'_>,
response: &mut FMT
) -> Result<()> where
FMT: Formatter,
Executes one SCPI message (terminated by \n
) and queue any errors.
Arguments
tokenizer
- A tokenizer created fromTokenizer::from_str(...)
. May be re-used if still has valid tokens and Ok() was returned.
Returns
Ok(())
- If message (and all units within) was executed successfullyErr(error)
- If parser detected or a command returned an error
pub fn get_stb(&self) -> u8
pub fn set_ese(&mut self, ese: u8)
pub fn get_ese(&mut self) -> u8
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Context<'a>
impl<'a> !Send for Context<'a>
impl<'a> !Sync for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more