Add empty structs for unix to bring lessen the amount of platfrom specific code users have to write
This commit is contained in:
parent
a2dc227fe4
commit
c9322e22c3
10
src/lib.rs
10
src/lib.rs
|
@ -32,9 +32,16 @@ use tokio_named_pipes::NamedPipe;
|
|||
|
||||
#[cfg(windows)]
|
||||
mod win_permissions;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub use win_permissions::SecurityAttributes;
|
||||
|
||||
#[cfg(unix)]
|
||||
mod unix_permissions;
|
||||
#[cfg(unix)]
|
||||
pub use unix_permissions::SecurityAttributes;
|
||||
|
||||
|
||||
|
||||
|
||||
/// For testing/examples
|
||||
|
@ -75,7 +82,6 @@ pub fn dummy_endpoint() -> String {
|
|||
/// ```
|
||||
pub struct Endpoint {
|
||||
path: String,
|
||||
#[cfg(windows)]
|
||||
security_attributes: SecurityAttributes,
|
||||
}
|
||||
|
||||
|
@ -123,7 +129,6 @@ impl Endpoint {
|
|||
tokio_uds::UnixListener::bind(&self.path, handle)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn set_security_attributes(&mut self, security_attributes: SecurityAttributes) {
|
||||
self.security_attributes = security_attributes;
|
||||
}
|
||||
|
@ -138,7 +143,6 @@ impl Endpoint {
|
|||
pub fn new(path: String) -> Self {
|
||||
Endpoint {
|
||||
path: path,
|
||||
#[cfg(windows)]
|
||||
security_attributes: SecurityAttributes::empty(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
/// A NOOP struct for bringing the API between Windows and Unix up to parity. To set permissions
|
||||
/// properly on Unix, you can just use `std::os::unix::fs::PermissionsExt`.
|
||||
pub struct SecurityAttributes {}
|
||||
|
||||
impl SecurityAttributes {
|
||||
pub fn empty() -> Self {Self{}}
|
||||
pub fn allow_everyone_connect() -> Self {Self{}}
|
||||
pub fn allow_everyone_create() -> Self {Self{}}
|
||||
}
|
Loading…
Reference in New Issue