Skip to main content

Session

Struct Session 

Source
pub struct Session<'t, T: Transport, C = ReadOnly> { /* private fields */ }

Implementations§

Source§

impl<'t, T: Transport> Session<'t, T, ReadOnly>

Source

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.

Source

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>

Source

pub fn class(&self) -> ObjectClass

Source

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.

Source

pub fn set_read_limit(&mut self, limit: Duration)

Override the per-frame READ_LIMIT for this session, including its close.

Source

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.

Source

pub async fn commit(self) -> Result<()>

Run the closing exchanges. Always prefer this over dropping.

Source

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.

Source

pub fn abort(self)

Abandon the transaction without running the closing exchanges.

Trait Implementations§

Source§

impl<T: Transport, C> Drop for Session<'_, T, C>

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§

§

impl<'t, T, C = ReadOnly> !UnwindSafe for Session<'t, T, C>

§

impl<'t, T, C> Freeze for Session<'t, T, C>

§

impl<'t, T, C> RefUnwindSafe for Session<'t, T, C>

§

impl<'t, T, C> Send for Session<'t, T, C>

§

impl<'t, T, C> Sync for Session<'t, T, C>

§

impl<'t, T, C> Unpin for Session<'t, T, C>

§

impl<'t, T, C> UnsafeUnpin for Session<'t, T, C>

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.