match signatures on unix
This commit is contained in:
parent
9d213dc4ac
commit
43c1f71cf6
|
@ -1,9 +1,16 @@
|
|||
use std::io;
|
||||
|
||||
/// 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 {
|
||||
/// New default security attributes.
|
||||
pub fn empty() -> Self { SecurityAttributes }
|
||||
pub fn allow_everyone_connect() -> Self { SecurityAttributes }
|
||||
pub fn allow_everyone_create() -> Self { SecurityAttributes }
|
||||
|
||||
/// New security attributes that allow everyone to connect.
|
||||
pub fn allow_everyone_connect() -> io::Result<Self> { Ok(SecurityAttributes) }
|
||||
|
||||
/// New security attributes that allow everyone to create.
|
||||
pub fn allow_everyone_create() -> io::Result<Self> { Ok(SecurityAttributes) }
|
||||
}
|
||||
|
|
|
@ -11,25 +11,30 @@ use std::io;
|
|||
use std::mem;
|
||||
use std::marker;
|
||||
|
||||
/// Security attributes.
|
||||
pub struct SecurityAttributes {
|
||||
attributes: Option<InnerAttributes>,
|
||||
}
|
||||
|
||||
impl SecurityAttributes {
|
||||
/// New default security attributes.
|
||||
pub fn empty() -> SecurityAttributes {
|
||||
SecurityAttributes { attributes: None }
|
||||
}
|
||||
|
||||
/// New default security attributes that allow everyone to connect.
|
||||
pub fn allow_everyone_connect() -> io::Result<SecurityAttributes> {
|
||||
let attributes = Some(InnerAttributes::allow_everyone(GENERIC_READ | FILE_WRITE_DATA)?);
|
||||
Ok(SecurityAttributes { attributes })
|
||||
}
|
||||
|
||||
/// New default security attributes that allow everyone to create.
|
||||
pub fn allow_everyone_create() -> io::Result<SecurityAttributes> {
|
||||
let attributes = Some(InnerAttributes::allow_everyone(GENERIC_READ | GENERIC_WRITE)?);
|
||||
Ok(SecurityAttributes { attributes })
|
||||
}
|
||||
|
||||
/// Return raw handle of security attributes.
|
||||
pub unsafe fn as_ptr(&mut self) -> PSECURITY_ATTRIBUTES {
|
||||
match self.attributes.as_mut() {
|
||||
Some(attributes) => attributes.as_ptr(),
|
||||
|
|
Loading…
Reference in New Issue