pub struct Name<'s>(/* private fields */);Expand description
Name for a local socket.
Due to significant differences between how different platforms name local sockets, there needs
to be a way to store and process those in a unified way while also retaining those
platform-specific pecularities. Name exists to bridge the gap between portability and
correctness, minimizing the amount of platform-dependent code in downstream programs.
§Creation
Two traits are used to create names from basic strings: ToFsName and
ToNsName.
§Validity
As mentioned in the module-level documentation, not all platforms support all types of local socket names. Names pointing to filesystem locations are only supported on Unix-like systems, and names pointing to an abstract namespace reserved specifically for local sockets are only available on Linux and Windows.
Instances of this type cannot be constructed from unsupported values. They can, however, be constructed from invalid ones.
Implementations§
Source§impl Name<'_>
impl Name<'_>
Sourcepub fn is_namespaced(&self) -> bool
pub fn is_namespaced(&self) -> bool
Returns true if the name points to a dedicated local socket namespace, false otherwise.
Sourcepub const fn is_path(&self) -> bool
pub const fn is_path(&self) -> bool
Returns true if the name is stored as a filesystem path, false otherwise.
Note that it is possible for .is_namespaced() and .is_path() to
return true simultaneously:
use interprocess::{local_socket::ToFsName, os::windows::local_socket::NamedPipe};
let name = r"\\.\pipe\example".to_fs_name::<NamedPipe>().unwrap();
assert!(name.is_namespaced()); // \\.\pipe\ is a namespace
assert!(name.is_path()); // \\.\pipe\example is a pathSourcepub fn into_owned(self) -> Name<'static>
pub fn into_owned(self) -> Name<'static>
Extends the lifetime to 'static, cloning if necessary.