Skip to main content

Resource

Trait Resource 

Source
pub trait Resource {
    // Required methods
    fn id(&self) -> ResourceId;
    fn on_apdu(&mut self, apdu: &[u8]) -> Result<ResourceOut>;

    // Provided methods
    fn on_open(&mut self) -> Result<ResourceOut> { ... }
    fn tick(&mut self, _elapsed: Duration) -> Result<ResourceOut> { ... }
    fn reset(&mut self) { ... }
}
Expand description

An EN 50221 application-layer resource.

Required Methods§

Source

fn id(&self) -> ResourceId

The resource this handler serves.

Source

fn on_apdu(&mut self, apdu: &[u8]) -> Result<ResourceOut>

An APDU arrived on this resource’s session.

Provided Methods§

Source

fn on_open(&mut self) -> Result<ResourceOut>

The session for this resource just opened.

Source

fn tick(&mut self, _elapsed: Duration) -> Result<ResourceOut>

Logical time advanced (for resources with timers, e.g. date_time).

Source

fn reset(&mut self)

Reset this resource’s internal state (r10-W-19): called on HostRequest::Init and HostRequest::Shutdown so a re-inserted CAM starts a fresh handshake against clean state rather than one latched by whatever the previous module left behind (e.g. a ready flag that never re-opens the profile_change gate on a second profile exchange). The default no-op is only correct for a resource that carries no state between calls.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§