1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::{
    db::{AccessoryListMember, AccessoryListPtr},
    Error,
};

pub mod bonjour;
pub mod mdns;

pub(crate) mod http;

mod ip;
mod tcp;

pub use self::ip::IpTransport;

/// `Transport` is implemented by the transport methods HAP supports. Currently, that's just
/// `IpTransport`.
pub trait Transport {
    /// Starts the transport.
    fn start(&mut self) -> Result<(), Error>;
    /// Stops the transport.
    fn stop(&self) -> Result<(), Error>;
    /// Adds an Accessory to the transport and returns a pointer to the added Accessory.
    fn add_accessory<A: 'static + AccessoryListMember + Send>(
        &mut self,
        accessory: A,
    ) -> Result<AccessoryListPtr, Error>;
    /// Takes a pointer to an Accessory and removes the Accessory from the transport.
    fn remove_accessory(&mut self, accessory: &AccessoryListPtr) -> Result<(), Error>;
}