Skip to main content

ChannelHandler

Trait ChannelHandler 

Source
pub trait ChannelHandler: Sized {
    type Error: Into<Error> + Error;

    const RECORDS_SESSION: bool = false;

    // Required methods
    fn new(
        handle: Handle,
        channel_id: ChannelId,
        session: Handle,
        dev: Arc<Device>,
        ctx: &ChannelContext,
    ) -> impl Future<Output = Result<Self, Self::Error>> + Send;
    fn handle_event(
        &mut self,
        event: &ChannelEvent,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

Handler for a channel session.

Provided Associated Constants§

Source

const RECORDS_SESSION: bool = false

Whether this handler streams its session to the policy’s recorders.

This is a fail-closed gate, not a hint. A policy rule with a non-empty recorders list obliges the server to record the session; a handler that leaves this false is refused such a connection outright rather than silently running it un-recorded. Only set it to true in a handler that actually calls SessionRecording.

Required Associated Types§

Source

type Error: Into<Error> + Error

Error this handler produces.

Required Methods§

Source

fn new( handle: Handle, channel_id: ChannelId, session: Handle, dev: Arc<Device>, ctx: &ChannelContext, ) -> impl Future<Output = Result<Self, Self::Error>> + Send

Construct a new per-channel handler.

ctx carries the single fail-closed authorization decision made in auth_none. Handlers MUST NOT re-evaluate policy or substitute a different user — the accepted identity is the sole authorization source.

This is async because a handler may have to reach the network before the session may start: a recorded session dials its recorder here, and a session that must be recorded but cannot be is refused by returning Err — so the shell is never spawned first and recorded second.

Source

fn handle_event( &mut self, event: &ChannelEvent, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Handle an event from the channel.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§