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>
impl<'a> AsyncTrust<'a>
Sourcepub const fn new(trust: &'a Trust) -> Self
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}Sourcepub fn evaluate(&self) -> Result<TrustEvaluateFuture<'a>>
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>
impl<'a> Clone for AsyncTrust<'a>
impl<'a> Copy for AsyncTrust<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
Available on macOS only.
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Available on macOS only.
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
Available on macOS only.
impl<T> CloneToUninit for Twhere
T: Clone,
Available on macOS only.