Skip to main content

SessionLayer

Struct SessionLayer 

Source
pub struct SessionLayer { /* private fields */ }
Expand description

The session table + session_nb allocator.

Implementations§

Source§

impl SessionLayer

Source

pub fn new() -> Self

New, empty session layer.

Source

pub fn resource_of(&self, session_nb: u16) -> Option<ResourceId>

Resource bound to session_nb, if open.

Source

pub fn sessions(&self) -> Vec<(u16, ResourceId)>

All open (session_nb, resource) pairs, ascending by session_nb.

Source

pub fn len(&self) -> usize

Number of open sessions.

Source

pub fn is_empty(&self) -> bool

Whether there are no open sessions.

Source

pub fn create_session(&mut self, resource: ResourceId) -> Vec<u8>

Open a session to a module-provided resource (host-initiated): returns the create_session SPDU to send. The session is recorded once the module’s create_session_response(ok) arrives.

Source

pub fn send_apdu(&self, session_nb: u16, apdu: &[u8]) -> Vec<u8>

Wrap an APDU for sending on session_nb (session_number + body).

Source

pub fn close(&mut self, session_nb: u16) -> Vec<u8>

Begin closing session_nb: returns the close_session_request SPDU.

Source

pub fn on_spdu( &mut self, spdu: &[u8], provides: impl Fn(ResourceId) -> bool, ) -> SessionOut

Handle one inbound SPDU. provides answers “does the host provide this resource?” for an incoming open_session_request.

Trait Implementations§

Source§

impl Debug for SessionLayer

Source§

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

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

impl Default for SessionLayer

Source§

fn default() -> SessionLayer

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

Auto Trait Implementations§

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> DescriptorObject for T
where T: Debug + Any + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrow as &dyn Any so the caller can downcast to the concrete type.
Source§

impl<T> ExtensionObject for T
where T: Debug + Any + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrow as &dyn Any so the caller can downcast to the concrete type.
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> TableObject for T
where T: Debug + Any + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrow as &dyn Any so the caller can downcast to the concrete type.
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.