anachro_client/
lib.rs

1//! # The Anachro Protocol Client Library
2//!
3//! This crate is used by devices acting as a Client of the Anachro Protocol
4
5#![no_std]
6
7pub use {
8    crate::{
9        client::{Client, PUBLISH_SHORTCODE_OFFSET},
10        client_io::{ClientIo, ClientIoError},
11        table::{Table, TableError},
12    },
13    anachro_icd::{self, arbitrator::SubMsg, ManagedString, Path, PubSubPath, Version},
14    postcard::{from_bytes, to_slice},
15};
16
17mod client;
18mod client_io;
19mod table;
20
21/// The main Client error type
22#[derive(Debug, PartialEq, Eq)]
23pub enum Error {
24    NotActive,
25    Busy,
26    UnexpectedMessage,
27    ClientIoError(ClientIoError),
28}
29
30impl From<ClientIoError> for Error {
31    fn from(other: ClientIoError) -> Self {
32        Error::ClientIoError(other)
33    }
34}
35
36/// A message that has been received FROM the Broker, TO the Client
37#[derive(Debug)]
38pub struct RecvMsg<T: Table> {
39    pub path: Path<'static>,
40    pub payload: T,
41}
42
43/// A message to be sent TO the Broker, FROM the Client
44#[derive(Debug)]
45pub struct SendMsg<'a> {
46    pub buf: &'a [u8],
47    pub path: &'static str,
48}