Skip to main content

SecurityAttributes

Struct SecurityAttributes 

Source
pub struct SecurityAttributes { /* private fields */ }
Expand description

An owned capture of a caller’s lpSecurityAttributes argument.

Three outcomes that a single nullable pointer runs together are kept apart by this type and AclState, because they are three different grants:

Caller passedMeaningRepresented as
NULL attributesdefault security, non-inheritable handleNone where a SecurityAttributes is expected
attributes with a NULL descriptordefault security, caller’s inheritance choicedescriptor is None
attributes with a descriptorthe caller’s securitydescriptor is Some

and within a descriptor, an absent DACL, a NULL DACL, and an empty DACL are three further distinct grants, reported by SecurityDescriptor::dacl.

§Example

The distinction a single nullable pointer runs together. Passing no attributes at all and passing attributes that carry no descriptor are different requests – the second still states an inheritance choice:

use windows_namespace_request_sys::SecurityAttributes;

// Attributes with no descriptor: default security, but the caller's
// inheritance choice is still carried.
let inheritable = SecurityAttributes::new(None, true);
assert!(inheritable.descriptor().is_none());
assert!(inheritable.inherit_handle());

let raw = inheritable.to_raw();
assert!(raw.lpSecurityDescriptor.is_null());
assert_ne!(raw.bInheritHandle, 0, "the choice survives into the Win32 struct");

// Passing *no* attributes is the third case, and is spelled `None` where a
// `SecurityAttributes` is expected rather than being confused with this.
let none: Option<SecurityAttributes> = None;
assert!(none.is_none());

Implementations§

Source§

impl SecurityAttributes

Source

pub fn new(descriptor: Option<SecurityDescriptor>, inherit_handle: bool) -> Self

Builds a capture from an already-owned descriptor and an inheritance choice.

Source

pub unsafe fn capture( attributes: *const SECURITY_ATTRIBUTES, ) -> Result<Option<Self>, SecurityCaptureError>

Captures the SECURITY_ATTRIBUTES at attributes.

A null attributes is not an error: it is the caller declining to supply any, which is reported as Ok(None) rather than being confused with attributes that carry no descriptor.

§Errors

Returns a SecurityCaptureError when the referenced descriptor cannot be captured.

§Safety

attributes, if non-null, must point to a SECURITY_ATTRIBUTES that stays valid for the duration of this call, as must any descriptor it names.

Source

pub fn descriptor(&self) -> Option<&SecurityDescriptor>

The captured descriptor, if the caller supplied one.

Source

pub fn inherit_handle(&self) -> bool

Whether the caller asked for the resulting handle to be inheritable.

Source

pub fn to_raw(&self) -> SECURITY_ATTRIBUTES

Rebuilds the SECURITY_ATTRIBUTES to pass to a Win32 call.

The result points into this value and must not outlive it.

Trait Implementations§

Source§

impl Clone for SecurityAttributes

Source§

fn clone(&self) -> SecurityAttributes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecurityAttributes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SecurityAttributes

Source§

impl PartialEq for SecurityAttributes

Source§

fn eq(&self, other: &SecurityAttributes) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SecurityAttributes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.