Struct otter_api_tests::imports::uds::nonblocking::UnixSeqpacketListener[]

#[repr(transparent)]
pub struct UnixSeqpacketListener { /* fields omitted */ }
Expand description

A non-blocking unix domain listener for sequential-packet connections.

Differs from UnixSeqpacketListener in that accept() returns non-blocking connection sockets and doesn’t block if no client connect()ions are pending.

This type can be used with mio if the mio feature is enabled:

uds = { version = "x.y", features=["mio"] }

Examples

use uds::nonblocking::{UnixSeqpacketListener, UnixSeqpacketConn};
use std::io::ErrorKind;

let listener = UnixSeqpacketListener::bind("nonblocking_seqpacket_listener.socket")
    .expect("Cannot create nonblocking seqpacket listener");

// doesn't block if no connections are waiting:
assert_eq!(listener.accept_unix_addr().unwrap_err().kind(), ErrorKind::WouldBlock);

// returned connections are nonblocking:
let _client = UnixSeqpacketConn::connect("nonblocking_seqpacket_listener.socket").unwrap();
let (conn, _addr) = listener.accept_unix_addr().unwrap();
assert_eq!(conn.recv(&mut[0u8; 20]).unwrap_err().kind(), ErrorKind::WouldBlock);

Registering with mio (v0.7):

use uds::nonblocking::{UnixSeqpacketListener, UnixSeqpacketConn};
use mio_07::{Poll, Events, Token, Interest};
use std::io::ErrorKind;

# let _ = std::fs::remove_file("seqpacket.sock");
let listener = UnixSeqpacketListener::bind("seqpacket.sock")
    .expect("create nonblocking seqpacket listener");

let mut poll = Poll::new().expect("create mio poll");
let mut events = Events::with_capacity(10);
poll.registry()
    .register(&mut &listener, Token(0), Interest::READABLE)
    .expect("register unix seqpacket listener with mio");

let _conn = UnixSeqpacketConn::connect("seqpacket.sock")
    .expect("create nonblocking seqpacket socket and connect to listener");

poll.poll(&mut events, None).expect("receive mio notifications");
let current_events = events.iter().collect::<Vec<_>>();
assert!(current_events.len() > 0);
assert_eq!(current_events[0].token(), Token(0));
let (_, _addr) = listener.accept_unix_addr().expect("accept connection");

Implementations

Creates a socket that listens for seqpacket connections on the specified socket file.

Creates a socket that listens for seqpacket connections on the specified address.

Returns the address this listener was bound to.

Accepts a non-blocking connection, non-blockingly.

Examples

Doesn’t block if no connections are waiting:

let _ = std::fs::remove_file("nonblocking_seqpacket_listener.socket");
let listener = UnixSeqpacketListener::bind("nonblocking_seqpacket_listener.socket")
    .expect("Cannot create nonblocking seqpacket listener");
assert_eq!(listener.accept_unix_addr().unwrap_err().kind(), ErrorKind::WouldBlock);
std::fs::remove_file("nonblocking_seqpacket_listener.socket").unwrap();

Returns the value of the SO_ERROR option.

This might never produce any errors for listeners. It is therefore unlikely to be useful, but is provided for parity with mios UnixListener.

Examples

let listener = uds::nonblocking::UnixSeqpacketListener::bind_unix_addr(
    &uds::UnixSocketAddr::new("@nonblocking_take_error").unwrap()
).unwrap();

assert!(listener.accept_unix_addr().is_err());
assert!(listener.take_error().unwrap().is_none());

Creates a new file descriptor listening for the same connections.

Trait Implementations

Extracts the raw file descriptor. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Constructs a new instance of Self from the given raw file descriptor. Read more

Consumes this object, returning the raw underlying file descriptor. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Use this to cast from one trait object type to another. Read more

Use this to upcast a trait to one of its supertraits. Read more

Use this to cast from one trait object type to another. This method is more customizable than the dyn_cast method. Here you can also specify the “source” trait from which the cast is defined. This can for example allow using casts from a supertrait of the current trait object. Read more

Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.