|  | 
| 18 | 18 | //! | 
| 19 | 19 | //! | 
| 20 | 20 | //! ## Example | 
| 21 |  | -//! ``` | 
| 22 |  | -//! # #[cfg(all(feature = "native_types", not(any(feature = "no_std", feature = "no_panic"))))] { | 
|  | 21 | +//! ```rust | 
| 23 | 22 | //! use asn1_der::{ | 
| 24 |  | -//! 	DerObject, | 
| 25 |  | -//! 	typed::{ DerEncodable, DerDecodable } | 
|  | 23 | +//!     DerObject, | 
|  | 24 | +//!     typed::{ DerEncodable, DerDecodable } | 
| 26 | 25 | //! }; | 
| 27 | 26 | //! | 
| 28 | 27 | //! /// An ASN.1-DER encoded integer `7` | 
|  | 
| 42 | 41 | //! // Encode a new `u8` | 
| 43 | 42 | //! let mut encoded_number = Vec::new(); | 
| 44 | 43 | //! 7u8.encode(&mut encoded_number).expect("Failed to encode string"); | 
| 45 |  | -//! # } | 
| 46 | 44 | //! ``` | 
| 47 | 45 | //! | 
| 48 | 46 | //! For the (de-)serialization of structs and similar via `derive`, see | 
|  | 
| 53 | 51 | //! There are also some direct `DerDecodable`/`DerDecodable` implementations for native Rust type | 
| 54 | 52 | //! equivalents: | 
| 55 | 53 | //!  - The ASN.1-`BOOLEAN` type as Rust-`bool` | 
| 56 |  | -//!  - The ASN.1-`INTEGER` type as Rust-[`u8`, `u16`, `u32`, `u64`, `u128`, `usize`, `i8`, `i16`, | 
| 57 |  | -//!    `i32`, `i64`, `i128`, `isize`] | 
|  | 54 | +//!  - The ASN.1-`INTEGER` type as Rust-[`u8`, `u16`, `u32`, `u64`, `u128`, `usize`, | 
|  | 55 | +//!    `i8`, `i16`, `i32`, `i64`, `i128`, `isize`] | 
| 58 | 56 | //!  - The ASN.1-`NULL` type as either `()` or `Option::None` (which allows the encoding of | 
| 59 | 57 | //!    optionals) | 
| 60 | 58 | //!  - The ASN.1-`OctetString` type as `Vec<u8>` | 
|  | 
| 77 | 75 | //!    `no_panic` and will be omitted if `no_panic` is enabled. | 
| 78 | 76 | //! | 
| 79 | 77 | //!    This crate might allocate memory in the following circumstances: | 
| 80 |  | -//!     - When writing to a dynamically allocating sink (e.g. `Vec<u8>`) | 
|  | 78 | +//!     - When writing to a dynamically allocating sink (e.g. `Vec<u8>`, `VecBacking(Vec<u8>)`) | 
| 81 | 79 | //!     - When decoding a native owned type such as `Vec<u8>`, `SequenceVec(Vec<T>)` or `String` | 
| 82 | 80 | //!     - During error propagation | 
| 83 | 81 | //! | 
|  | 
| 93 | 91 | //! | 
| 94 | 92 | //!    This crate by itself does never call `abort` directly. | 
| 95 | 93 | //! | 
|  | 94 | +//! Due to the limitations described above, the following functions are mutually exclusive to | 
|  | 95 | +//! `no_panic` and disabled if `no_panic` is set: | 
|  | 96 | +//!  - Error stacking/propagation (`propagate` is a no-op if compiled with `no_panic`) | 
|  | 97 | +//!  - The sink implementation for a byte vector (`impl Sink for Vec<u8>`) | 
|  | 98 | +//!  - The `VecBacking(Vec<u8>)` type | 
|  | 99 | +//!  - The native OctetString type which uses `Vec<u8>` (`impl<'a> DerDecodable<'a> for Vec<u8>` and | 
|  | 100 | +//!    `impl DerEncodable for Vec<u8>`) | 
|  | 101 | +//!  - The native Sequence type wrapper `SequenceVec` since it is based upon `Vec` | 
|  | 102 | +//!  - The native Utf8String type based upon `String` (`impl<'a> DerDecodable<'a> for String` and | 
|  | 103 | +//!    `impl DerEncodable for String`) | 
|  | 104 | +//! | 
| 96 | 105 | //! | 
| 97 | 106 | //! ## Zero-Copy | 
| 98 | 107 | //! The crate is designed to be as much zero-copy as possible. In fact this means that the | 
| 99 | 108 | //! `DerObject` type and all typed views are zero-copy views over the underlying slice. Of course, | 
| 100 |  | -//! zero-copy is not always reasonable: The `new`-constructors are not zero-copy because they | 
|  | 109 | +//! ero-copy is not always reasonable: The `new`-constructors are not zero-copy because they | 
| 101 | 110 | //! construct a new object into a sink and the native type implementations are not zero-copy because | 
| 102 | 111 | //! they are either `Copy`-types (e.g. `u128`) or owned (e.g. `String`). | 
| 103 | 112 | //! | 
|  | 
| 122 | 131 | #[doc(hidden)] | 
| 123 | 132 | pub mod error; | 
| 124 | 133 | mod data; | 
| 125 |  | -mod der; | 
|  | 134 | +#[doc(hidden)] | 
|  | 135 | +pub mod der; | 
| 126 | 136 | #[cfg(feature = "native_types")] | 
| 127 | 137 | 	pub mod typed; | 
| 128 | 138 | 
 | 
|  | 
0 commit comments