Skip to main content

App

Trait App 

Source
pub trait App: Sized {
    type Settings: DeserializeOwned;
    type AppEvent: Send + 'static;

    // Required method
    fn new(settings: Self::Settings) -> Self;

    // Provided methods
    fn handle_connect(
        &mut self,
        _connection: &mut Connection<Self>,
    ) -> Result<(), Error> { ... }
    fn handle_packet(
        &mut self,
        _connection: &mut Connection<Self>,
        _stream_id: StreamId,
        _packet: Datagram,
    ) -> Result<(), Error> { ... }
    fn handle_new_settings(
        &mut self,
        _connection: &mut Connection<Self>,
        _settings: Self::Settings,
    ) -> Result<(), Error> { ... }
    fn handle_ptp_event(
        &mut self,
        _connection: &mut Connection<Self>,
        _ptp_event: PtpEvent,
    ) -> Result<(), Error> { ... }
    fn handle_goose_packet(
        &mut self,
        _connection: &mut Connection<Self>,
        _goose_event: GooseEvent,
    ) -> Result<(), Error> { ... }
    fn handle_event(
        &mut self,
        _connection: &mut Connection<Self>,
        _event: Self::AppEvent,
    ) -> Result<(), Error> { ... }
}
Expand description

Callbacks implemented by an app.

Required Associated Types§

Required Methods§

Source

fn new(settings: Self::Settings) -> Self

Provided Methods§

Source

fn handle_connect( &mut self, _connection: &mut Connection<Self>, ) -> Result<(), Error>

Called when the app first connects to the framework.

Source

fn handle_packet( &mut self, _connection: &mut Connection<Self>, _stream_id: StreamId, _packet: Datagram, ) -> Result<(), Error>

Called when the app receives a packet from a stream-id it has connect_to_stream’d to.

Source

fn handle_new_settings( &mut self, _connection: &mut Connection<Self>, _settings: Self::Settings, ) -> Result<(), Error>

Called when app settings are updated. Return Ok if the new settings can be accomodated without a restart and Err to restart the app with the new settings.

Source

fn handle_ptp_event( &mut self, _connection: &mut Connection<Self>, _ptp_event: PtpEvent, ) -> Result<(), Error>

Called when PTP status is updated. Note that in order to get PTP events you need to be connected to the StreamId::SYS_TIME stream.

Source

fn handle_goose_packet( &mut self, _connection: &mut Connection<Self>, _goose_event: GooseEvent, ) -> Result<(), Error>

Called when Goose status is updated for a GOOSE stream that has been connected to.

Source

fn handle_event( &mut self, _connection: &mut Connection<Self>, _event: Self::AppEvent, ) -> Result<(), Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§