Skip to main content

protocol

Attribute Macro protocol 

Source
#[protocol]
Expand description

Declare an application protocol: value types, a read-only state struct and a command trait.

ⓘ
#[bern::protocol(namespace = "player", version = 1)]
pub mod player {
    use bern::prelude::*;

    #[state]
    pub struct State { pub position_ms: i64 }

    #[commands]
    pub trait Commands {
        /// Move the playback position
        fn seek(&mut self, position_ms: i64) -> Result<(), CommandError>;
    }
}