Struct reserve_port::ReservedPort
source · pub struct ReservedPort { /* private fields */ }
Expand description
A port, that at the time of creation, is guaranteed to be free for use by the OS.
This also guarantees not to clash with other ReservedPort
objects.
The motivation of this library is to allow one to reserve many ports, ensure they don’t clash with each other, and then let them go when they are no longer needed.
Implementations§
source§impl ReservedPort
impl ReservedPort
pub fn random_with_tcp<I>(ip: I) -> Result<(Self, TcpListener)>
pub fn random_permanently_reserved_tcp<I>( ip: I ) -> Result<(TcpListener, SocketAddr)>
pub fn random() -> Result<Self>
pub fn random_permanently_reserved() -> Result<u16>
sourcepub fn reserve_port(port: u16) -> Result<()>
pub fn reserve_port(port: u16) -> Result<()>
Permanently reserves the given port as being offlimits (for this library).
This is useful if you have connected to a socket yourself, and wish to avoid clashing with this library.
pub fn port(&self) -> u16
Trait Implementations§
source§impl Debug for ReservedPort
impl Debug for ReservedPort
Auto Trait Implementations§
impl RefUnwindSafe for ReservedPort
impl Send for ReservedPort
impl Sync for ReservedPort
impl Unpin for ReservedPort
impl UnwindSafe for ReservedPort
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
Mutably borrows from an owned value. Read more