Connection

Struct Connection 

Source
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>

Source

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.

Source

pub fn load_primitives(&mut self, prims: Primitives)

Inform libccp of new measurements.

Source

pub fn primitives(&self, _token: &Datapath) -> Primitives

Source

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.

Trait Implementations§

Source§

impl<'dp, T: CongestionOps> Deref for Connection<'dp, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'dp, T: CongestionOps> DerefMut for Connection<'dp, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'dp, T: CongestionOps> Drop for Connection<'dp, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'dp, T: CongestionOps> Send for Connection<'dp, T>

Auto Trait Implementations§

§

impl<'dp, T> Freeze for Connection<'dp, T>

§

impl<'dp, T> !RefUnwindSafe for Connection<'dp, T>

§

impl<'dp, T> !Sync for Connection<'dp, T>

§

impl<'dp, T> Unpin for Connection<'dp, T>
where T: Unpin,

§

impl<'dp, T> !UnwindSafe for Connection<'dp, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.