pub struct Session<'t, T: Transport, C = ReadOnly> { /* private fields */ }Implementations§
Source§impl<'t, T: Transport> Session<'t, T, ReadOnly>
impl<'t, T: Transport> Session<'t, T, ReadOnly>
Sourcepub async fn open(transport: &'t mut T, class: ObjectClass) -> Result<Self>
pub async fn open(transport: &'t mut T, class: ObjectClass) -> Result<Self>
Open a transaction scoped to one ObjectClass.
The class matters: STATUS and the addressing operations all report on
whichever class was opened, so opening the wrong one yields correct-looking
numbers about the wrong thing.
Sourcepub fn allow_destructive_writes(self) -> Session<'t, T, ReadWrite>
pub fn allow_destructive_writes(self) -> Session<'t, T, ReadWrite>
Escalate to a session that can mutate the device.
Source§impl<T: Transport, C> Session<'_, T, C>
impl<T: Transport, C> Session<'_, T, C>
pub fn class(&self) -> ObjectClass
Sourcepub fn instrument_changed(&self) -> bool
pub fn instrument_changed(&self) -> bool
Whether an unsolicited cmd::CHANGED notification arrived during this
session.
The device queues one on its own when its contents change outside the session —
a front-panel STORE, for instance — and Session::request drains it rather than
mistaking it for a reply. true means the instrument changed under us: state
read earlier in this session may be stale.
Sourcepub fn set_read_limit(&mut self, limit: Duration)
pub fn set_read_limit(&mut self, limit: Duration)
Override the per-frame READ_LIMIT for this session, including its close.
Sourcepub async fn probe(
&mut self,
service: Service,
subsystem: u32,
command: u32,
args: &[u8],
limit: Duration,
) -> Result<Option<Message>>
pub async fn probe( &mut self, service: Service, subsystem: u32, command: u32, args: &[u8], limit: Duration, ) -> Result<Option<Message>>
Send an arbitrary command and return whatever comes back, enforcing nothing.
For reverse-engineering commands that have no typed operation yet. Unlike
Session::request this accepts a reply that is not command + 1 and a non-zero
status, because on an undocumented command both are results rather than faults —
a device that does not implement one still answers, with a status saying so.
Ok(None) means it said nothing within limit.
Call Self::commit_with_read_limit with the same limit to bound cleanup too.
Queued cmd::CHANGED notifications are drained as in Session::request, so a
front-panel STORE cannot be mistaken for the probe’s answer.
§Warning
This sends bytes no capture has ever shown the device being sent. Unknown commands have been reported to leave instrument firmware in a state only a power cycle clears, and a write-shaped command reaching a real object destroys it. Probe read-shaped commands, on backed-up content, or not at all.
Sourcepub async fn commit(self) -> Result<()>
pub async fn commit(self) -> Result<()>
Run the closing exchanges. Always prefer this over dropping.
Sourcepub async fn commit_with_read_limit(self, limit: Duration) -> Result<()>
pub async fn commit_with_read_limit(self, limit: Duration) -> Result<()>
Commit with a bounded close for exploratory probes. The consumed session’s ordinary read behavior is unchanged.