pubtrait IntoResult { /// The `Ok` type for the result. type Ok;
/// Unsafe in our implementors because they take a pointer and have no way /// to ensure that the pointer is valid. An invalid pointer could cause UB /// in `impl Drop for Scoped`. unsafefn into_result(self) -> Result<Self::Ok, Error>;
}
// This can be used to implement `IntoResult` for pointer types that do not make // sense as smart pointers. For smart pointers use `scoped_ptr!`.
macro_rules! impl_into_result {
($pointer:ty) => { impl $crate::err::IntoResult for *mut $pointer { type Ok = *mut $pointer;
#[test] fn is_err() {
set_error_code(err::ssl::SSL_ERROR_BAD_MAC_READ); let r = secstatus_to_res(SECFailure);
assert!(r.is_err()); match r.unwrap_err() {
Error::NssError { name, code, desc } => {
assert_eq!(name, "SSL_ERROR_BAD_MAC_READ");
assert_eq!(code, -12273);
assert_eq!(
desc, "SSL received a record with an incorrect Message Authentication Code."
);
}
_ => unreachable!(),
}
}
#[test] fn is_err_zero_code() {
set_error_code(0); let r = secstatus_to_res(SECFailure);
assert!(r.is_err()); match r.unwrap_err() {
Error::NssError { name, code, .. } => {
assert_eq!(name, "UNKNOWN_ERROR");
assert_eq!(code, 0); // Note that we don't test |desc| here because that comes from // strerror(0), which is platform-dependent.
}
_ => unreachable!(),
}
}
#[test] fn blocked() {
set_error_code(err::nspr::PR_WOULD_BLOCK_ERROR); let r = secstatus_to_res(SECFailure);
assert!(r.is_err());
assert!(is_blocked(&r)); match r.unwrap_err() {
Error::NssError { name, code, desc } => {
assert_eq!(name, "PR_WOULD_BLOCK_ERROR");
assert_eq!(code, -5998);
assert_eq!(desc, "The operation would have blocked");
}
_ => panic!("bad error type"),
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.