Lines Matching +full:write +full:- +full:error
1 //! Error types.
15 pub type Result<T> = core::result::Result<T, Error>;
17 /// Error type.
19 pub struct Error { struct
20 /// Kind of error.
23 /// Position inside of message where error occurred.
27 impl Error { argument
28 /// Create a new [`Error`].
29 pub fn new(kind: ErrorKind, position: Length) -> Error { in new() argument
30 Error { in new()
39 pub fn incomplete(actual_len: Length) -> Self { in incomplete()
51 pub fn kind(self) -> ErrorKind { in kind()
55 /// Get the position inside of the message where the error occurred.
56 pub fn position(self) -> Option<Length> { in position()
62 pub(crate) fn nested(self, nested_position: Length) -> Self { in nested()
74 impl std::error::Error for Error {} implementation
76 impl fmt::Display for Error { implementation
77 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
78 write!(f, "{}", self.kind)?; in fmt()
81 write!(f, " at DER byte {}", pos)?; in fmt()
88 impl From<ErrorKind> for Error { implementation
89 fn from(kind: ErrorKind) -> Error { in from() argument
90 Error { in from()
97 impl From<Infallible> for Error { implementation
98 fn from(_: Infallible) -> Error { in from() argument
103 impl From<TryFromIntError> for Error { implementation
104 fn from(_: TryFromIntError) -> Error { in from() argument
105 Error { in from()
112 impl From<Utf8Error> for Error { implementation
113 fn from(err: Utf8Error) -> Error { in from() argument
114 Error { in from()
122 impl From<alloc::string::FromUtf8Error> for Error { implementation
123 fn from(err: alloc::string::FromUtf8Error) -> Error { in from() argument
129 impl From<const_oid::Error> for Error { implementation
130 fn from(_: const_oid::Error) -> Error { in from() argument
136 impl From<pem::Error> for Error { implementation
137 fn from(err: pem::Error) -> Error { in from() argument
143 impl From<std::io::Error> for Error { implementation
144 fn from(err: std::io::Error) -> Error { in from() argument
155 impl From<time::error::ComponentRange> for Error { implementation
156 fn from(_: time::error::ComponentRange) -> Error { in from() argument
161 /// Error type.
165 /// Date-and-time related errors.
168 /// This error indicates a previous DER parsing operation resulted in
169 /// an error and tainted the state of a `Decoder` or `Encoder`.
175 /// File not found error.
218 /// This error is intended to be used by libraries which parse DER-based
222 /// to determine which OID(s) are causing the error (and then potentially
226 /// OID value that was unrecognized by a parser for a DER-based format.
233 /// `SET` ordering error: items not in canonical order.
244 Pem(pem::Error),
258 /// The "tag number" is the lower 5-bits of a tag's octet.
259 /// This error occurs in the case that all 5-bits are set to `1`,
260 /// which indicates a multi-byte tag which is unsupported by this library.
290 /// UTF-8 errors.
302 /// returning an error.
303 pub fn at(self, position: Length) -> Error { in at() argument
304 Error::new(self, position) in at()
309 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
311 ErrorKind::DateTime => write!(f, "date/time error"), in fmt()
312 ErrorKind::Failed => write!(f, "operation failed"), in fmt()
314 ErrorKind::FileNotFound => write!(f, "file not found"), in fmt()
318 } => write!( in fmt()
324 ErrorKind::Io(err) => write!(f, "I/O error: {:?}", err), in fmt()
325 ErrorKind::IndefiniteLength => write!(f, "indefinite length disallowed"), in fmt()
326 ErrorKind::Length { tag } => write!(f, "incorrect length for {}", tag), in fmt()
328 write!(f, "ASN.1 {} not canonically encoded as DER", tag) in fmt()
330 ErrorKind::OidMalformed => write!(f, "malformed OID"), in fmt()
333 write!(f, "unknown/unsupported OID: {}", oid) in fmt()
335 ErrorKind::SetDuplicate => write!(f, "SET OF contains duplicate"), in fmt()
336 ErrorKind::SetOrdering => write!(f, "SET OF ordering error"), in fmt()
337 ErrorKind::Overflow => write!(f, "integer overflow"), in fmt()
338 ErrorKind::Overlength => write!(f, "ASN.1 DER message is too long"), in fmt()
340 ErrorKind::Pem(e) => write!(f, "PEM error: {}", e), in fmt()
342 ErrorKind::PermissionDenied => write!(f, "permission denied"), in fmt()
343 ErrorKind::Reader => write!(f, "reader does not support the requested operation"), in fmt()
344 ErrorKind::TagModeUnknown => write!(f, "unknown tag mode"), in fmt()
345 ErrorKind::TagNumberInvalid => write!(f, "invalid tag number"), in fmt()
347 write!(f, "unexpected ASN.1 DER tag: ")?; in fmt()
350 write!(f, "expected {}, ", tag)?; in fmt()
353 write!(f, "got {}", actual) in fmt()
356 write!(f, "unknown/unsupported ASN.1 DER tag: 0x{:02x}", byte) in fmt()
359 write!( in fmt()
365 ErrorKind::Utf8(e) => write!(f, "{}", e), in fmt()
366 ErrorKind::Value { tag } => write!(f, "malformed ASN.1 DER value for {}", tag), in fmt()