hopr_transport_session/
lib.rspub mod errors;
pub mod initiation;
mod manager;
pub mod traits;
pub mod types;
pub use manager::{DispatchResult, SessionManager, SessionManagerConfig};
use crate::types::SessionTarget;
use hopr_network_types::prelude::state::SessionFeature;
pub use hopr_network_types::types::*;
use libp2p_identity::PeerId;
pub use types::{IncomingSession, Session, SessionId, SESSION_USABLE_MTU_SIZE};
#[cfg(feature = "serde")]
use {
serde::{Deserialize, Serialize},
serde_with::{As, DisplayFromStr},
};
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, strum::EnumIter, strum::Display, strum::EnumString)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Capability {
Segmentation,
Retransmission,
RetransmissionAckOnly,
NoDelay,
}
impl IntoIterator for Capability {
type Item = SessionFeature;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
match self {
Capability::Segmentation => vec![],
Capability::Retransmission => vec![
SessionFeature::AcknowledgeFrames,
SessionFeature::RequestIncompleteFrames,
SessionFeature::RetransmitFrames,
],
Capability::RetransmissionAckOnly => {
vec![SessionFeature::AcknowledgeFrames, SessionFeature::RetransmitFrames]
}
Capability::NoDelay => vec![SessionFeature::NoDelay],
}
.into_iter()
}
}
#[derive(Debug, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SessionClientConfig {
#[cfg_attr(feature = "serde", serde(with = "As::<DisplayFromStr>"))]
pub peer: PeerId,
pub path_options: RoutingOptions,
pub target: SessionTarget,
pub capabilities: Vec<Capability>,
}