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>
impl<T: Transport> Device<T>
Sourcepub fn transport(&mut self) -> &mut T
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.
pub fn into_transport(self) -> T
Sourcepub async fn read<R>(
&mut self,
class: ObjectClass,
f: impl AsyncFnOnce(&mut Session<'_, T, ReadOnly>) -> Result<R>,
) -> Result<R>
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.
Sourcepub async fn destructive<R>(
&mut self,
class: ObjectClass,
f: impl AsyncFnOnce(&mut Session<'_, T, ReadWrite>) -> Result<R>,
) -> Result<R>
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.
Sourcepub fn take_changed(&mut self) -> bool
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.
Sourcepub async fn geometry(&mut self) -> Result<&Geometry>
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.
Sourcepub async fn write(
&mut self,
class: ObjectClass,
at: Location,
file: &[u8],
name: &str,
timestamp: u32,
) -> Result<()>
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.