pub struct Error(/* private fields */);Expand description
A Security Framework error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn from_code(code: OSStatus) -> Self
pub fn from_code(code: OSStatus) -> Self
Creates a new Error from a status code.
The code must not be zero
Sourcepub fn message(self) -> Option<String>
pub fn message(self) -> Option<String>
Returns a string describing the current error, if available.
Sourcepub fn code(self) -> OSStatus
pub fn code(self) -> OSStatus
Returns the code of the current error.
Examples found in repository?
examples/find_internet_password.rs (line 30)
7fn main() {
8 #[cfg(target_os = "macos")]
9 {
10 let hostname = "example.com";
11 let username = "rusty";
12 let res = SecKeychain::default().unwrap().find_internet_password(
13 hostname,
14 None,
15 username,
16 "",
17 None,
18 SecProtocolType::Any,
19 SecAuthenticationType::Any,
20 );
21 match res {
22 Ok((password, _)) => {
23 println!(
24 "Password for {}@{} is {} bytes long",
25 username,
26 hostname,
27 password.len()
28 );
29 }
30 Err(err) if err.code() == -128 => {
31 eprintln!("Account was found in the Keychain, but user denied access");
32 }
33 Err(err) => {
34 eprintln!("Password not found. Open Keychain Access.app and add internet password for '{}' at 'https://{}': {:?}",
35 username, hostname, err);
36 }
37 }
38 }
39}Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl<S> From<Error> for ClientHandshakeError<S>
impl<S> From<Error> for ClientHandshakeError<S>
Source§impl<S> From<Error> for HandshakeError<S>
impl<S> From<Error> for HandshakeError<S>
impl Copy for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more