Struct orkhon::prelude::ops::nn::tract_downcast_rs::__std::os::unix::net::SocketAncillary [−][src]
unix_socket_ancillary_data
)A Unix socket Ancillary data struct.
Example
#![feature(unix_socket_ancillary_data)] use std::os::unix::net::{UnixStream, SocketAncillary, AncillaryData}; use std::io::IoSliceMut; fn main() -> std::io::Result<()> { let sock = UnixStream::connect("/tmp/sock")?; let mut fds = [0; 8]; let mut ancillary_buffer = [0; 128]; let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); let mut buf = [1; 8]; let mut bufs = &mut [IoSliceMut::new(&mut buf[..])][..]; sock.recv_vectored_with_ancillary(bufs, &mut ancillary)?; for ancillary_result in ancillary.messages() { if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { for fd in scm_rights { println!("receive file descriptor: {}", fd); } } } Ok(()) }
Implementations
impl<'a> SocketAncillary<'a>
[src]
pub fn new(buffer: &'a mut [u8]) -> SocketAncillary<'a>
[src]
unix_socket_ancillary_data
)Create an ancillary data with the given buffer.
Example
#![feature(unix_socket_ancillary_data)] use std::os::unix::net::SocketAncillary; let mut ancillary_buffer = [0; 128]; let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
pub fn capacity(&self) -> usize
[src]
unix_socket_ancillary_data
)Returns the capacity of the buffer.
pub fn len(&self) -> usize
[src]
unix_socket_ancillary_data
)Returns the number of used bytes.
pub fn messages(&self) -> Messages<'_>ⓘNotable traits for Messages<'a>
impl<'a> Iterator for Messages<'a> type Item = Result<AncillaryData<'a>, AncillaryError>;
[src]
Notable traits for Messages<'a>
impl<'a> Iterator for Messages<'a> type Item = Result<AncillaryData<'a>, AncillaryError>;
unix_socket_ancillary_data
)Returns the iterator of the control messages.
pub fn truncated(&self) -> bool
[src]
unix_socket_ancillary_data
)Is true
if during a recv operation the ancillary was truncated.
Example
#![feature(unix_socket_ancillary_data)] use std::os::unix::net::{UnixStream, SocketAncillary}; use std::io::IoSliceMut; fn main() -> std::io::Result<()> { let sock = UnixStream::connect("/tmp/sock")?; let mut ancillary_buffer = [0; 128]; let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); let mut buf = [1; 8]; let mut bufs = &mut [IoSliceMut::new(&mut buf[..])][..]; sock.recv_vectored_with_ancillary(bufs, &mut ancillary)?; println!("Is truncated: {}", ancillary.truncated()); Ok(()) }
pub fn add_fds(&mut self, fds: &[i32]) -> bool
[src]
unix_socket_ancillary_data
)Add file descriptors to the ancillary data.
The function returns true
if there was enough space in the buffer.
If there was not enough space then no file descriptors was appended.
Technically, that means this operation adds a control message with the level SOL_SOCKET
and type SCM_RIGHTS
.
Example
#![feature(unix_socket_ancillary_data)] use std::os::unix::net::{UnixStream, SocketAncillary}; use std::os::unix::io::AsRawFd; use std::io::IoSliceMut; fn main() -> std::io::Result<()> { let sock = UnixStream::connect("/tmp/sock")?; let mut ancillary_buffer = [0; 128]; let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); ancillary.add_fds(&[sock.as_raw_fd()][..]); let mut buf = [1; 8]; let mut bufs = &mut [IoSliceMut::new(&mut buf[..])][..]; sock.send_vectored_with_ancillary(bufs, &mut ancillary)?; Ok(()) }
pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool
[src]
unix_socket_ancillary_data
)Add credentials to the ancillary data.
The function returns true
if there was enough space in the buffer.
If there was not enough space then no credentials was appended.
Technically, that means this operation adds a control message with the level SOL_SOCKET
and type SCM_CREDENTIALS
or SCM_CREDS
.
pub fn clear(&mut self)
[src]
unix_socket_ancillary_data
)Clears the ancillary data, removing all values.
Example
#![feature(unix_socket_ancillary_data)] use std::os::unix::net::{UnixStream, SocketAncillary, AncillaryData}; use std::io::IoSliceMut; fn main() -> std::io::Result<()> { let sock = UnixStream::connect("/tmp/sock")?; let mut fds1 = [0; 8]; let mut fds2 = [0; 8]; let mut ancillary_buffer = [0; 128]; let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); let mut buf = [1; 8]; let mut bufs = &mut [IoSliceMut::new(&mut buf[..])][..]; sock.recv_vectored_with_ancillary(bufs, &mut ancillary)?; for ancillary_result in ancillary.messages() { if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { for fd in scm_rights { println!("receive file descriptor: {}", fd); } } } ancillary.clear(); sock.recv_vectored_with_ancillary(bufs, &mut ancillary)?; for ancillary_result in ancillary.messages() { if let AncillaryData::ScmRights(scm_rights) = ancillary_result.unwrap() { for fd in scm_rights { println!("receive file descriptor: {}", fd); } } } Ok(()) }
Trait Implementations
impl<'a> Debug for SocketAncillary<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for SocketAncillary<'a>
[src]
impl<'a> Send for SocketAncillary<'a>
[src]
impl<'a> Sync for SocketAncillary<'a>
[src]
impl<'a> Unpin for SocketAncillary<'a>
[src]
impl<'a> !UnwindSafe for SocketAncillary<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Notable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Send + Sync + Any,
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,