Struct Incoming
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Incoming<'a> { pub(in ::os::unix::net::listener) listener: &'a UnixListener }
An iterator over incoming connections to a UnixListener.
It will never return None.
Examples
use std::thread;
use std::os::unix::net::{UnixStream, UnixListener};
fn handle_client(stream: UnixStream) {
// ...
}
fn main() -> std::io::Result<()> {
let listener = UnixListener::bind("/path/to/the/socket")?;
for stream in listener.incoming() {
match stream {
Ok(stream) => {
thread::spawn(|| handle_client(stream));
}
Err(err) => {
break;
}
}
}
Ok(())
}
Fields
listener: &'a UnixListener
Trait Implementations
impl<'a> Debug for Incoming<'a>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'a> Iterator for Incoming<'a>
type Item = Result<UnixStream, Error>;fn next(&mut self) -> Option<Result<UnixStream>>fn size_hint(&self) -> (usize, Option<usize>)
Auto Trait Implementations
impl<'a> Freeze for Incoming<'a>
impl<'a> RefUnwindSafe for Incoming<'a>
impl<'a> Send for Incoming<'a>
impl<'a> Sync for Incoming<'a>
impl<'a> Unpin for Incoming<'a>
impl<'a> UnsafeUnpin for Incoming<'a>
impl<'a> UnwindSafe for Incoming<'a>
Blanket Implementations
impl<I> IntoIterator for Incoming<'a>
where
I: Iterator,
type Item = <I as Iterator>::Item;type IntoIter = I;fn into_iter(self) -> I
impl<T> Any for Incoming<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Incoming<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Incoming<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Incoming<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for Incoming<'a>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for Incoming<'a>
impl<T, U> Into<U> for Incoming<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Incoming<'a>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Incoming<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>