Struct shadow_rs::utility::sockaddr::SockaddrUnix
source · pub struct SockaddrUnix<T>where
T: Borrow<sockaddr_un>,{ /* private fields */ }
Expand description
A Unix socket address.
Typically will be used as an owned address SockaddrUnix<libc::sockaddr_un>
or a borrowed
address SockaddrUnix<&libc::sockaddr_un>
, and you can convert between them using methods such
as as_ref
or into_owned
.
Implementations§
source§impl<T> SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
impl<T> SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
sourcepub fn new(addr: T, len: socklen_t) -> Option<Self>
pub fn new(addr: T, len: socklen_t) -> Option<Self>
Get a new SockaddrUnix
for a libc::sockaddr_un
. The libc::sockaddr_un
must be
properly initialized. Will return None
if the length is too short, too long, or if
sun_family
is not AF_UNIX
.
sourcepub fn as_path(&self) -> Option<&CStr>
pub fn as_path(&self) -> Option<&CStr>
If the socket address represents a pathname address, returns the C string representing the filesystem path.
sourcepub fn as_abstract(&self) -> Option<&[u8]>
pub fn as_abstract(&self) -> Option<&[u8]>
If the socket address represents an abstract address, returns the bytes representing the
name of the abstract socket address. These bytes do not include the nul byte at
sun_path[0]
.
sourcepub fn is_unnamed(&self) -> bool
pub fn is_unnamed(&self) -> bool
Is the unix socket address unnamed? On Linux, unnamed unix sockets are unnamed if their
length is size_of::<libc::sa_family_t>()
.
sourcepub fn into_owned(self) -> SockaddrUnix<sockaddr_un>
pub fn into_owned(self) -> SockaddrUnix<sockaddr_un>
Get an owned unix socket address.
sourcepub fn as_ref(&self) -> SockaddrUnix<&sockaddr_un>
pub fn as_ref(&self) -> SockaddrUnix<&sockaddr_un>
Get a borrowed unix socket address.
sourcepub fn as_ptr(&self) -> (*const sockaddr_un, socklen_t)
pub fn as_ptr(&self) -> (*const sockaddr_un, socklen_t)
Get a pointer to the unix socket address. All fields of the libc::sockaddr_un
will be
properly initialized.
source§impl<T> SockaddrUnix<T>where
T: BorrowMut<sockaddr_un>,
impl<T> SockaddrUnix<T>where
T: BorrowMut<sockaddr_un>,
sourcepub fn as_mut(&mut self) -> SockaddrUnix<&mut sockaddr_un>
pub fn as_mut(&mut self) -> SockaddrUnix<&mut sockaddr_un>
Get a mutably borrowed unix socket address.
source§impl SockaddrUnix<sockaddr_un>
impl SockaddrUnix<sockaddr_un>
sourcepub fn new_path(path: &CStr) -> Option<Self>
pub fn new_path(path: &CStr) -> Option<Self>
Get a new SockaddrUnix
with the given path. Will return None
if the path is empty or is
too large.
sourcepub fn new_abstract(name: &[u8]) -> Option<Self>
pub fn new_abstract(name: &[u8]) -> Option<Self>
Get a new SockaddrUnix
with the given abstract address name. The name does not include the
required nul byte at sun_path[0]
. Will return None
if the name is too large.
sourcepub fn new_unnamed() -> SockaddrUnix<sockaddr_un>
pub fn new_unnamed() -> SockaddrUnix<sockaddr_un>
Get a new unnamed unix socket address.
Trait Implementations§
source§impl<T> Clone for SockaddrUnix<T>
impl<T> Clone for SockaddrUnix<T>
source§fn clone(&self) -> SockaddrUnix<T>
fn clone(&self) -> SockaddrUnix<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Debug for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
impl<T> Debug for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
source§impl<T> Display for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
impl<T> Display for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
source§impl<T> From<SockaddrUnix<T>> for SockaddrStoragewhere
T: Borrow<sockaddr_un>,
impl<T> From<SockaddrUnix<T>> for SockaddrStoragewhere
T: Borrow<sockaddr_un>,
source§fn from(addr: SockaddrUnix<T>) -> Self
fn from(addr: SockaddrUnix<T>) -> Self
source§impl<T> PartialEq for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
impl<T> PartialEq for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
impl<T> Copy for SockaddrUnix<T>
impl<T> Eq for SockaddrUnix<T>where
T: Borrow<sockaddr_un>,
Auto Trait Implementations§
impl<T> Freeze for SockaddrUnix<T>where
T: Freeze,
impl<T> RefUnwindSafe for SockaddrUnix<T>where
T: RefUnwindSafe,
impl<T> Send for SockaddrUnix<T>where
T: Send,
impl<T> Sync for SockaddrUnix<T>where
T: Sync,
impl<T> Unpin for SockaddrUnix<T>where
T: Unpin,
impl<T> UnwindSafe for SockaddrUnix<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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