Skip to main content

Device

Struct Device 

Source
pub struct Device<T: Transport> { /* private fields */ }
Expand description

An attached instrument. See the module documentation for the shape.

Implementations§

Source§

impl<T: Transport> Device<T>

Source

pub fn new(transport: T) -> Self

Wrap an already-open transport.

Source

pub fn transport(&mut self) -> &mut T

The transport itself, for what the brackets cannot express — op::recover, Session::probe, or a backend-specific call.

Source

pub fn into_transport(self) -> T

Source

pub async fn read<R>( &mut self, class: ObjectClass, f: impl AsyncFnOnce(&mut Session<'_, T, ReadOnly>) -> Result<R>, ) -> Result<R>

Run a chain of read-only operations in one transaction.

Cleanup is attempted whether the chain succeeds or fails. When both fail the chain’s error is reported, except that a transport failure closing outranks a device refusal in the chain: the instrument saying no is a reply, and the pipe having failed is the finding the caller has to act on.

⚠️ The close is what clears the instrument’s progress label. A transaction abandoned after a read has painted "Uploading..." leaves that label on the display with no way out but a power cycle; the bracket exists so no ? can do that.

Source

pub async fn destructive<R>( &mut self, class: ObjectClass, f: impl AsyncFnOnce(&mut Session<'_, T, ReadWrite>) -> Result<R>, ) -> Result<R>

Run a chain that may mutate the instrument, in one transaction.

The name is the consent: this is the only route to a ReadWrite session, and a write can destroy an object the caller never named. It brackets its chain exactly as Self::read does, error precedence included.

Source

pub fn take_changed(&mut self) -> bool

Whether the instrument reported changing under us since this was last asked, and clear it.

Every bracket preserves its session’s Session::instrument_changed flag, so state read during any completed transaction may be stale.

Source

pub async fn geometry(&mut self) -> Result<&Geometry>

The instrument’s Geometry, read on first use and kept.

Storing and deleting content leaves every field of the partition table unchanged.

Confirmed on hardware.

The bank table is kept on the same assumption. The sample bank declares a capacity equal to its highest occupied slot plus one, which a high-water mark would also produce, and no recording holds a BANKS reply from after a store that moves a bank’s top slot.

Inferred from specimens; not confirmed on hardware.

Source

pub async fn write( &mut self, class: ObjectClass, at: Location, file: &[u8], name: &str, timestamp: u32, ) -> Result<()>

Write a file using the allocation unit reported for its partition.

A library write is refused 0x16 without a prepared block per storage block of body, so block-allocated storage reserves in the transfer’s transaction, sized by that partition’s AllocationUnit and the body the file carries — the CBIN body, which is shorter than the file by its header.

⚠️ Most classes refuse a write into an occupied slot with status 0x4; see ObjectClass::overwrites_in_place. Emptying the slot first, and putting the occupant back when the write fails, is the caller’s to sequence.

Auto Trait Implementations§

§

impl<T> Freeze for Device<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Device<T>
where T: RefUnwindSafe,

§

impl<T> Send for Device<T>
where T: Send,

§

impl<T> Sync for Device<T>
where T: Sync,

§

impl<T> Unpin for Device<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Device<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Device<T>
where T: UnwindSafe,

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.