pub struct Endpoint { /* private fields */ }Expand description
A WireGuard endpoint capable of communicating with multiple remote peers.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn new(my_key: NodeKeyPair) -> Self
pub fn new(my_key: NodeKeyPair) -> Self
Construct a new endpoint with the given keypair.
Sourcepub fn add_peer(&mut self, cfg: PeerConfig) -> Option<PeerId>
pub fn add_peer(&mut self, cfg: PeerConfig) -> Option<PeerId>
Add a new peer.
Returns a handle to the newly configured peer, or None if a peer is already configured with the given node key.
Sourcepub fn remove_peer(&mut self, peer: PeerId) -> bool
pub fn remove_peer(&mut self, peer: PeerId) -> bool
Remove the given peer.
Returns whether the peer in question existed.
Sourcepub fn send(
&mut self,
packets: impl IntoIterator<Item = (PeerId, Vec<PacketMut>)>,
) -> SendResult
pub fn send( &mut self, packets: impl IntoIterator<Item = (PeerId, Vec<PacketMut>)>, ) -> SendResult
Send packets to peers.
Sourcepub fn recv(
&mut self,
packets: impl IntoIterator<Item = PacketMut>,
) -> RecvResult
pub fn recv( &mut self, packets: impl IntoIterator<Item = PacketMut>, ) -> RecvResult
Receive packets from peers.
Sourcepub fn dispatch_events(&mut self, now: Instant) -> EventResult
pub fn dispatch_events(&mut self, now: Instant) -> EventResult
Dispatch time-based events that are due to occur at or before the given instant.
Use Endpoint::next_event to know when to call dispatch_events. It is inefficient but
harmless to call it more frequently than specified by Endpoint::next_event.
Sourcepub fn next_event(&self) -> Option<TimeRange>
pub fn next_event(&self) -> Option<TimeRange>
Returns the next time range in which Endpoint::dispatch_events should next be called to
dispatch events.
Endpoint::dispatch_events should be called at some point in the returned TimeRange
to keep the wireguard state machine functioning correctly.
See Scheduler::next_dispatch_range for additional details.
Sourcepub fn peer_key(&self, id: PeerId) -> Option<NodePublicKey>
pub fn peer_key(&self, id: PeerId) -> Option<NodePublicKey>
Return the node key for the selected peer.
Sourcepub fn peer_id(&self, key: NodePublicKey) -> Option<PeerId>
pub fn peer_id(&self, key: NodePublicKey) -> Option<PeerId>
Return the peer id that has the selected node key.
Auto Trait Implementations§
impl Freeze for Endpoint
impl RefUnwindSafe for Endpoint
impl Send for Endpoint
impl Sync for Endpoint
impl Unpin for Endpoint
impl UnsafeUnpin for Endpoint
impl UnwindSafe for Endpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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