@@ -11,6 +11,12 @@ use core::cmp::Ordering;
11
11
#[ cfg( feature = "alloc" ) ]
12
12
use crate :: SliceWriter ;
13
13
14
+ /// Trait representing value that will be serialized as Any
15
+ pub trait AnyLike {
16
+ /// Is this value an ASN.1 `NULL` value?
17
+ fn is_null ( & self ) -> bool ;
18
+ }
19
+
14
20
/// ASN.1 `ANY`: represents any explicitly tagged ASN.1 value.
15
21
///
16
22
/// This is a zero-copy reference type which borrows from the input data.
@@ -74,11 +80,6 @@ impl<'a> AnyRef<'a> {
74
80
Ok ( decoder. finish ( result) ?)
75
81
}
76
82
77
- /// Is this value an ASN.1 `NULL` value?
78
- pub fn is_null ( self ) -> bool {
79
- self == Self :: NULL
80
- }
81
-
82
83
/// Attempt to decode this value an ASN.1 `SEQUENCE`, creating a new
83
84
/// nested reader and calling the provided argument with it.
84
85
pub fn sequence < F , T , E > ( self , f : F ) -> Result < T , E >
@@ -93,6 +94,12 @@ impl<'a> AnyRef<'a> {
93
94
}
94
95
}
95
96
97
+ impl < ' a > AnyLike for AnyRef < ' a > {
98
+ fn is_null ( & self ) -> bool {
99
+ * self == Self :: NULL
100
+ }
101
+ }
102
+
96
103
impl < ' a > Choice < ' a > for AnyRef < ' a > {
97
104
fn can_decode ( _: Tag ) -> bool {
98
105
true
@@ -316,9 +323,8 @@ mod allocating {
316
323
}
317
324
}
318
325
319
- impl Any {
320
- /// Is this value an ASN.1 `NULL` value?
321
- pub fn is_null ( & self ) -> bool {
326
+ impl AnyLike for Any {
327
+ fn is_null ( & self ) -> bool {
322
328
self . owned_to_ref ( ) == AnyRef :: NULL
323
329
}
324
330
}
0 commit comments