lib3h 0.0.3-alpha1

The lib3h p2p communication rust library.
Documentation
use crate::transport::{error::TransportError, ConnectionId};
use url::Url;

/// Commands that can be sent to an implementor of the Transport trait and handled during `process()`
#[derive(Debug, PartialEq, Clone)]
pub enum TransportCommand {
    Connect(Url),
    Send(Vec<ConnectionId>, Vec<u8>),
    SendAll(Vec<u8>),
    Close(ConnectionId),
    CloseAll,
    Bind(Url),
}

/// Events that can be generated during a `process()`
#[derive(Debug, PartialEq, Clone)]
pub enum TransportEvent {
    TransportError(ConnectionId, TransportError),
    /// an outgoing connection has been established
    ConnectResult(ConnectionId),
    /// we have received an incoming connection
    Connection(ConnectionId),
    /// We have received data from a connection
    Received(ConnectionId, Vec<u8>),
    Closed(ConnectionId),
}