Struct HqEndpoint

Source
pub struct HqEndpoint { /* private fields */ }
Expand description

A harlequinn client or server endpoint.

Implementations§

Source§

impl HqEndpoint

Source

pub fn new_client(protocol: &str) -> Self

Creates a new client endpoint.

Doesn’t listen for incoming connections, use connect to start a connection to a server.

Source

pub fn new_server( protocol: &str, socket_addr: SocketAddr, certificate: Certificate, private_key: PrivateKey, ) -> Self

Creates a new server endpoint.

Listens for incoming connections.

Source

pub fn connect<S: ToString>( &mut self, server_addr: SocketAddr, server_name: S, certificate: Certificate, ) -> PeerId

Initiate a connection to a server endpoint.

Raises ConnectionFailed on failure, and ConnectionRequested on success.

Source

pub fn disconnect(&mut self, peer_id: PeerId, reason: String)

Disconnects a peer, ending the connection.

reason is not preserved intact, and will be mangled on the other side, but can be used to provide human-readable reasons.

Source

pub fn accept(&mut self, peer_id: PeerId)

Accepts a pending connection.

Source

pub fn reject(&mut self, peer_id: PeerId)

Rejects a pending connection.

Source

pub fn send_datagram(&mut self, peer_id: PeerId, bytes: Bytes)

Send an unreliable datagram to a peer.

If the peer is taking too long to respond to messages, this may disconnect the peer.

Source

pub fn send_message( &mut self, peer_id: PeerId, bytes: Bytes, order: MessageOrder, )

Send a reliable message over the main stream to a peer.

Messages with ordered set to true will arrive in order at the peer.

If the peer is taking too long to respond to messages, this may disconnect the peer.

Source

pub fn poll_events(&mut self, events: &mut Vec<EndpointEvent>)

Polls for events and stores them in the given events buffer.

This must be called frequently, or the endpoint will run out of space in the events channel and stall.

Trait Implementations§

Source§

impl Drop for HqEndpoint

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V