CheckedConn

Struct CheckedConn 

Source
pub struct CheckedConn<T: CheckedPermissions> { /* private fields */ }
Expand description

A typed connection to a running KeyOS server.

CheckedConn<P> is the lower-level message sender used by the public API crates. Most application code should call a crate-specific wrapper such as BluetoothApi::enable_ble or SettingsApi::get_locale instead of sending raw message values directly. When adding a wrapper method, choose the send method that matches the message trait implemented by #[derive(Message)]:

Message traitSend methodUse when
BlockingScalarsend_blocking_scalar or try_send_blocking_scalarThe message fits in scalar registers and returns a response.
Scalarsend_scalar, try_send_scalar, or send_scalar_nowaitThe message fits in scalar registers and has no response.
BlockingArchivesend_blocking_archive or try_send_blocking_archiveThe message is serialized with rkyv and returns a response.
Archivesend_archive, try_send_archive, or send_archive_nowaitThe message is serialized with rkyv and has no response.
LendMutlend_mutThe caller lends a mutable memory range to the server and waits for the server to finish with it.
Movesend_move, try_send_move, or send_move_nowaitThe caller transfers ownership of a memory range to the server.
ScalarSubscription / ArchiveSubscriptionsubscribe_scalar or subscribe_archiveThe caller registers its ServerContext to receive future events.

For normal system API wrappers, prefer the infallible methods when the target service is mandatory: delivery failure means the system service has crashed or disconnected, and the device should reboot rather than route unreachable error handling through every caller. Use try_* methods when the API intentionally exposes optional service availability, caller-recoverable transport failure, or explicit queue-full handling.

Implementations§

Source§

impl<P: CheckedPermissions> CheckedConn<P>

Source

pub fn try_connect() -> Option<Self>

Permission: none

Open a connection to the server based on the server name.

Source

pub fn try_connect_with_timeout(timeout: Duration) -> Option<Self>

Permission: none

Source

pub fn get_remote_pid(&self) -> PID

Permission: none

Get the remote process ID.

Source

pub fn unchecked(&self) -> CheckedConn<WithAllPermissions<P>>

Permission: none

Get a version of this connection that does not do compile-time permission checking.

Use this only for infrastructure code that has already enforced permissions another way. Normal API wrappers should keep their P: MessageAllowed<M> bounds so missing permissions fail at compile time.

Source

pub fn send_blocking_scalar<M>(&self, msg: M) -> M::Response

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a BlockingScalar message and wait for its response.

Panics if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn try_send_blocking_scalar<M>(&self, msg: M) -> Result<M::Response, Error>

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a BlockingScalar message and wait for its response.

Returns the underlying transport error if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn send_scalar_async<M, SR>(&self, msg: M, context: &mut ServerContext<SR>)

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a BlockingScalar message and handle its response later on the supplied ServerContext.

Source

pub fn try_send_scalar_async<M, SR>( &self, msg: M, context: &mut ServerContext<SR>, ) -> Result<(), Error>

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a BlockingScalar message asynchronously, returning the transport error if the message cannot be queued.

Source

pub fn send_scalar<M>(&self, msg: M)
where M: Scalar, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a fire-and-forget Scalar message.

Blocks if the message queue is full and panics if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn try_send_scalar<M>(&self, msg: M) -> Result<(), Error>
where M: Scalar, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a fire-and-forget Scalar message.

Blocks if the message queue is full and returns the delivery error if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn send_scalar_nowait<M>(&self, msg: M) -> Result<(), Error>
where M: Scalar, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a fire-and-forget Scalar message without waiting for queue space.

Returns an error if the queue is full or delivery otherwise fails. Can be used in an IRQ handler context.

Source

pub fn send_blocking_archive<M>(&self, msg: M) -> M::Response

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a BlockingArchive message and wait for its response.

Panics if the message cannot be delivered.

Source

pub fn try_send_blocking_archive<M>(&self, msg: M) -> Result<M::Response, Error>

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a BlockingArchive message and wait for its response.

Returns the underlying transport error if the message cannot be delivered or decoded.

Source

pub fn try_send_archive<M>(&self, msg: M) -> Result<(), Error>
where M: Archive, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a fire-and-forget Archive message.

Blocks if the message queue is full and returns the delivery error if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn send_archive<M>(&self, msg: M)
where M: Archive, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a fire-and-forget Archive message.

Blocks if the message queue is full and panics if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn send_archive_nowait<M>(&self, msg: M) -> Result<(), Error>
where M: Archive, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a fire-and-forget Archive message without waiting for queue space.

Returns an error if the queue is full or delivery otherwise fails. Can be used in an IRQ handler context.

Source

pub fn lend_mut<M>(&self, msg: M) -> M::Response
where M: LendMut, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a LendMut message and wait for the server to finish with the lent memory.

Use this for APIs that pass a [xous::MemoryRange] to a server for in-place reads or writes.

Source

pub fn send_move<M>(&self, msg: M)
where M: Move, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a Move message, transferring ownership of its memory range.

Blocks if the message queue is full and panics if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn try_send_move<M>(&self, msg: M) -> Result<(), Error>
where M: Move, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a Move message, transferring ownership of its memory range.

Blocks if the message queue is full and returns the delivery error if the message cannot be delivered.

Warning: Cannot be used in an IRQ handler context.

Source

pub fn send_move_nowait<M>(&self, msg: M) -> Result<(), Error>
where M: Move, P: MessageAllowed<M>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Send a Move message without waiting for queue space.

Returns an error if the queue is full or delivery otherwise fails. Can be used in an IRQ handler context.

Source

pub fn subscribe_archive<M, SR>( &self, msg: M, context: &mut ServerContext<SR>, ) -> Result<(), M::Error>
where M: ArchiveSubscription + 'static, P: MessageAllowed<M>, SR: ArchiveEventHandler<M::Event>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Subscribe to archive events.

Source

pub fn subscribe_archive_infallible<M, SR>( &self, msg: M, context: &mut ServerContext<SR>, )
where M: ArchiveSubscription<Error = Infallible> + 'static, P: MessageAllowed<M>, SR: ArchiveEventHandler<M::Event>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Subscribe to archive events (infallible version).

Source

pub fn subscribe_scalar<M, SR>( &self, msg: M, context: &mut ServerContext<SR>, ) -> Result<(), M::Error>
where M: ScalarSubscription + 'static, P: MessageAllowed<M>, SR: ScalarEventHandler<M::Event>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Subscribe to scalar events.

Source

pub fn subscribe_scalar_infallible<M, SR>( &self, msg: M, context: &mut ServerContext<SR>, )
where M: ScalarSubscription<Error = Infallible> + 'static, P: MessageAllowed<M>, SR: ScalarEventHandler<M::Event>,

Permission: TBD (MessageAllowed<M>)

Groups: TBD

Sender policy: TBD

Grant timing: TBD

Subscribe to scalar events (infallible version).

Trait Implementations§

Source§

impl<T: Clone + CheckedPermissions> Clone for CheckedConn<T>

Source§

fn clone(&self) -> CheckedConn<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: CheckedPermissions> Debug for CheckedConn<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: CheckedPermissions> Default for CheckedConn<P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<P: CheckedPermissions> From<u32> for CheckedConn<P>

Source§

fn from(cid: CID) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for CheckedConn<T>

§

impl<T> RefUnwindSafe for CheckedConn<T>

§

impl<T> Send for CheckedConn<T>

§

impl<T> Sync for CheckedConn<T>

§

impl<T> Unpin for CheckedConn<T>

§

impl<T> UnwindSafe for CheckedConn<T>

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.