File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 291
291
//! # }
292
292
//! ```
293
293
//!
294
+ //! ## Owned vs Borrowed
295
+ //!
296
+ //! This crate exposes owned and borrowed objects for representing the same structure.
297
+ //!
298
+ //! [`RefToOwned`] and [`OwnedToRef`] are provided to convert objects from one to the other.
299
+ //!
294
300
//! # See also
295
301
//! For more information about ASN.1 DER we recommend the following guides:
296
302
//!
322
328
//! [`UintRef`]: asn1::UintRef
323
329
//! [`UtcTime`]: asn1::UtcTime
324
330
//! [`Utf8StringRef`]: asn1::Utf8StringRef
331
+ //! [`RefToOwned`]: referenced::RefToOwned
332
+ //! [`OwnedToRef`]: referenced::OwnedToRef
325
333
326
334
#[ cfg( feature = "alloc" ) ]
327
335
#[ allow( unused_imports) ]
Original file line number Diff line number Diff line change 1
1
//! A module for working with referenced data.
2
2
3
3
/// A trait for borrowing data from an owned struct
4
+ ///
5
+ /// This converts an object owning the data to one that will borrowing the content.
6
+ /// The newly created object lifetime will be tied to the object owning the data.
7
+ ///
8
+ /// This is similar to [`alloc::borrow::Borrow`] or [`core::convert::AsRef`] but this returns
9
+ /// an owned structure that references directly the backing slices instead of borrowing
10
+ /// the whole structure.
4
11
pub trait OwnedToRef {
5
12
/// The resulting type referencing back to Self
6
13
type Borrowed < ' a >
@@ -13,7 +20,10 @@ pub trait OwnedToRef {
13
20
14
21
/// A trait for cloning a referenced structure and getting owned objects
15
22
///
16
- /// This is the pendant to [`OwnedToRef`]
23
+ /// This is the pendant to [`OwnedToRef`].
24
+ ///
25
+ /// This converts an object borrowing data to one that will copy the data over and
26
+ /// own the content.
17
27
pub trait RefToOwned < ' a > {
18
28
/// The resulting type after obtaining ownership.
19
29
type Owned : OwnedToRef < Borrowed < ' a > = Self >
Original file line number Diff line number Diff line change @@ -21,9 +21,13 @@ use crate::{fingerprint, FingerprintBytes};
21
21
use der:: pem:: PemLabel ;
22
22
23
23
/// [`SubjectPublicKeyInfo`] with [`AnyRef`] algorithm parameters, and [`BitStringRef`] params.
24
+ ///
25
+ /// This is the borrowing-pendant to [`SubjectPublicKeyInfoOwned`].
24
26
pub type SubjectPublicKeyInfoRef < ' a > = SubjectPublicKeyInfo < AnyRef < ' a > , BitStringRef < ' a > > ;
25
27
26
28
/// [`SubjectPublicKeyInfo`] with [`Any`] algorithm parameters, and [`BitString`] params.
29
+ ///
30
+ /// This is the owning-pendant to [`SubjectPublicKeyInfoRef`].
27
31
#[ cfg( feature = "alloc" ) ]
28
32
pub type SubjectPublicKeyInfoOwned = SubjectPublicKeyInfo < Any , BitString > ;
29
33
You can’t perform that action at this time.
0 commit comments