Skip to main content

AsyncTrust

Struct AsyncTrust 

Source
pub struct AsyncTrust<'a> { /* private fields */ }
Available on crate feature async only.
Expand description

Borrowed async wrapper for SecTrustRef evaluation.

Implementations§

Source§

impl<'a> AsyncTrust<'a>

Source

pub const fn new(trust: &'a Trust) -> Self

Create a borrowed async wrapper around a trust object.

Examples found in repository?
examples/16_async_trust.rs (line 19)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    use security::async_api::AsyncTrust;
9    use security::{Certificate, Policy, Trust};
10
11    executor::block_on(async {
12        let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13        let policy = Policy::basic_x509()?;
14        let mut trust = Trust::new(&certificate, &[policy])?;
15        trust.set_anchor_certificates(&[certificate])?;
16        trust.set_anchor_certificates_only(true)?;
17        trust.set_network_fetch_allowed(false)?;
18
19        AsyncTrust::new(&trust).evaluate()?.await?;
20        println!("chain_len={}", trust.certificate_chain()?.len());
21        Ok::<(), Box<dyn std::error::Error>>(())
22    })
23}
Source

pub fn evaluate(&self) -> Result<TrustEvaluateFuture<'a>>

Start SecTrustEvaluateAsyncWithError and await its callback.

Examples found in repository?
examples/16_async_trust.rs (line 19)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    use security::async_api::AsyncTrust;
9    use security::{Certificate, Policy, Trust};
10
11    executor::block_on(async {
12        let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13        let policy = Policy::basic_x509()?;
14        let mut trust = Trust::new(&certificate, &[policy])?;
15        trust.set_anchor_certificates(&[certificate])?;
16        trust.set_anchor_certificates_only(true)?;
17        trust.set_network_fetch_allowed(false)?;
18
19        AsyncTrust::new(&trust).evaluate()?.await?;
20        println!("chain_len={}", trust.certificate_chain()?.len());
21        Ok::<(), Box<dyn std::error::Error>>(())
22    })
23}

Trait Implementations§

Source§

impl<'a> Clone for AsyncTrust<'a>

Source§

fn clone(&self) -> Self

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<'a> Copy for AsyncTrust<'a>

Source§

impl<'a> Debug for AsyncTrust<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Send for AsyncTrust<'a>

Available on macOS only.
§

impl<'a> !Sync for AsyncTrust<'a>

Available on macOS only.
§

impl<'a> Freeze for AsyncTrust<'a>

Available on macOS only.
§

impl<'a> RefUnwindSafe for AsyncTrust<'a>

Available on macOS only.
§

impl<'a> Unpin for AsyncTrust<'a>

Available on macOS only.
§

impl<'a> UnsafeUnpin for AsyncTrust<'a>

Available on macOS only.
§

impl<'a> UnwindSafe for AsyncTrust<'a>

Available on macOS only.

Blanket Implementations§

Source§

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

Available on macOS only.
Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Available on macOS only.
Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Available on macOS only.
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,

Available on macOS only.
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

Available on macOS only.
Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Available on macOS only.
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,

Available on macOS only.
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>,

Available on macOS only.
Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Available on macOS only.
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.