pub struct Connection<'dp, T: CongestionOps + 'static>(/* private fields */);Expand description
An individual Connection.
Connections cannot outlive the Datapath they belong to, since they contain
a pointer to memory that is freed when Datapath is dropped.
So, their lifetime is 'dp from the &'dp Datapath.
You can regain access to the impl CongestionOps by dereferencing Connection
struct Dp();
impl libccp::DatapathOps for Dp {
fn send_msg(&mut self, _: &[u8]) { /* ___ */ }
}
struct Cn(u32);
impl libccp::CongestionOps for Cn {
fn set_cwnd(&mut self, cwnd: u32) { /* ___ */ }
fn set_rate_abs(&mut self, cwnd: u32) { /* ___ */ }
}
fn main() {
let d = libccp::Datapath::init(Dp()).unwrap();
let mut c = libccp::Connection::start(&d, Cn(0), libccp::FlowInfo::default()).unwrap();
c.load_primitives(libccp::Primitives::default());
c.0 = 1;
}Implementations§
Source§impl<'dp, T: CongestionOps + 'static> Connection<'dp, T>
impl<'dp, T: CongestionOps + 'static> Connection<'dp, T>
Sourcepub fn start(
token: &'dp Datapath,
conn: T,
flow_info: FlowInfo,
) -> Result<Self, LibccpError>
pub fn start( token: &'dp Datapath, conn: T, flow_info: FlowInfo, ) -> Result<Self, LibccpError>
Call this function when a connection starts.
conn: impl CongestionOps represents per-connection state,
and how to mutate it in response to changing congestion windows
or rates.
Sourcepub fn load_primitives(&mut self, prims: Primitives)
pub fn load_primitives(&mut self, prims: Primitives)
Inform libccp of new measurements.
pub fn primitives(&self, _token: &Datapath) -> Primitives
Sourcepub fn invoke(&mut self) -> Result<(), LibccpError>
pub fn invoke(&mut self) -> Result<(), LibccpError>
Tell libccp to invoke. This will run the congestion control’s datapath program,
and potentially result in calls to the CongestionOps callbacks.
Therefore, ensure that when you call this function, you are not holding locks that
the CongestionOps functionality tries to acquire - this will deadlock.