Endpoint

Struct Endpoint 

Source
pub struct Endpoint<S, Q> { /* private fields */ }
Expand description

The main entry point to the library

This object performs no I/O whatsoever. Instead, it consumes incoming packets and connection-generated events via handle and handle_event.

Implementations§

Source§

impl<S, Q> Endpoint<S, Q>
where S: Pool<Q>, Q: Pool<u16>,

Source

pub fn new() -> Self

Create a new server endpoint

Source

pub fn with_capacity(capacity: usize) -> Result<Self, S::Error>

Create a new server endpoint with a specific capacity

Source

pub fn close(&mut self)

Close the endpoint

Source

pub fn accept(&mut self) -> Result<ConnectionHandle, Error<S::Error, Q::Error>>

Accept a new connection

Source

pub fn recv<'container, 'innards>( &mut self, ch: ConnectionHandle, msg: Message<'container, 'innards>, ) -> Result<Query<'container, 'innards>, Error<S::Error, Q::Error>>

Handle an incoming query message

Source

pub fn response( &mut self, qh: QueryHandle, question: Question<'_>, ) -> Result<Outgoing, Error<S::Error, Q::Error>>

Generate a response for a question

Source

pub fn drain_query( &mut self, qh: QueryHandle, ) -> Result<(), Error<S::Error, Q::Error>>

Handle a query drain event

Source

pub fn drain_connection( &mut self, ch: ConnectionHandle, ) -> Result<Closed<Q>, Error<S::Error, Q::Error>>

Handle a connection drain event

Trait Implementations§

Source§

impl<S, Q> Default for Endpoint<S, Q>
where S: Pool<Q>, Q: Pool<u16>,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, Q> Freeze for Endpoint<S, Q>
where S: Freeze,

§

impl<S, Q> RefUnwindSafe for Endpoint<S, Q>

§

impl<S, Q> Send for Endpoint<S, Q>
where S: Send, Q: Send,

§

impl<S, Q> Sync for Endpoint<S, Q>
where S: Sync, Q: Sync,

§

impl<S, Q> Unpin for Endpoint<S, Q>
where S: Unpin, Q: Unpin,

§

impl<S, Q> UnwindSafe for Endpoint<S, Q>
where S: UnwindSafe, Q: UnwindSafe,

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.