Skip to content

Commit 48cb730

Browse files
authored
der: remove SequenceOf and SetOf (#2220)
As suggested in #2218. These were built on a half-baked internal implementation of an `ArrayVec`-like type. Instead of vendoring our own half-baked `ArrayVec` type, we should choose an optional dependency we can use which lets you do things like borrow slices of the contents (something ours doesn't support because it used `Option<T>` as its internal representation). Until we choose such a type, this removes all of the related functionality, so it can be added-back in the future without it being a breaking change.
1 parent 781961c commit 48cb730

File tree

9 files changed

+49
-661
lines changed

9 files changed

+49
-661
lines changed

der/src/arrayvec.rs

Lines changed: 0 additions & 146 deletions
This file was deleted.

der/src/asn1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ mod private;
2626
#[cfg(feature = "real")]
2727
mod real;
2828
mod sequence;
29+
#[cfg(feature = "alloc")]
2930
mod sequence_of;
31+
#[cfg(feature = "alloc")]
3032
mod set_of;
3133
mod teletex_string;
3234
mod utc_time;
@@ -48,8 +50,6 @@ pub use self::{
4850
printable_string::PrintableStringRef,
4951
private::{Private, PrivateRef},
5052
sequence::{Sequence, SequenceRef},
51-
sequence_of::{SequenceOf, SequenceOfIter},
52-
set_of::{SetOf, SetOfIter},
5353
teletex_string::TeletexStringRef,
5454
utc_time::UtcTime,
5555
utf8_string::Utf8StringRef,

der/src/asn1/context_specific.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ impl_custom_class_ref!(
2727
#[allow(clippy::unwrap_used)]
2828
mod tests {
2929
use super::ContextSpecific;
30-
use crate::{
31-
Decode, Encode, SliceReader, TagMode, TagNumber,
32-
asn1::{BitStringRef, ContextSpecificRef, SetOf, Utf8StringRef},
33-
};
30+
use crate::{Decode, Encode, SliceReader, TagMode, TagNumber, asn1::BitStringRef};
3431
use hex_literal::hex;
3532

33+
#[cfg(feature = "alloc")]
34+
use crate::asn1::{ContextSpecificRef, SetOfVec, Utf8StringRef};
35+
3636
// Public key data from `pkcs8` crate's `ed25519-pkcs8-v2.der`
3737
const EXAMPLE_BYTES: &[u8] =
3838
&hex!("A123032100A3A7EAE3A8373830BC47E1167BC50E1DB551999651E0E2DC587623438EAC3F31");
@@ -125,12 +125,13 @@ mod tests {
125125
}
126126

127127
#[test]
128+
#[cfg(feature = "alloc")]
128129
fn context_specific_explicit_ref() {
129-
let mut set = SetOf::new();
130+
let mut set = SetOfVec::new();
130131
set.insert(8u16).unwrap();
131132
set.insert(7u16).unwrap();
132133

133-
let field = ContextSpecificRef::<SetOf<u16, 2>> {
134+
let field = ContextSpecificRef::<SetOfVec<u16>> {
134135
value: &set,
135136
tag_number: TagNumber(2),
136137
tag_mode: TagMode::Explicit,
@@ -147,7 +148,7 @@ mod tests {
147148
);
148149

149150
let mut reader = SliceReader::new(encoded).unwrap();
150-
let field = ContextSpecific::<SetOf<u16, 2>>::decode_explicit(&mut reader, TagNumber(2))
151+
let field = ContextSpecific::<SetOfVec<u16>>::decode_explicit(&mut reader, TagNumber(2))
151152
.unwrap()
152153
.unwrap();
153154

@@ -157,15 +158,16 @@ mod tests {
157158
}
158159

159160
#[test]
161+
#[cfg(feature = "alloc")]
160162
fn context_specific_implicit_ref() {
161163
let hello = Utf8StringRef::new("Hello").unwrap();
162164
let world = Utf8StringRef::new("world").unwrap();
163165

164-
let mut set = SetOf::new();
166+
let mut set = SetOfVec::new();
165167
set.insert(hello).unwrap();
166168
set.insert(world).unwrap();
167169

168-
let field = ContextSpecificRef::<SetOf<Utf8StringRef<'_>, 2>> {
170+
let field = ContextSpecificRef::<SetOfVec<Utf8StringRef<'_>>> {
169171
value: &set,
170172
tag_number: TagNumber(2),
171173
tag_mode: TagMode::Implicit,
@@ -183,7 +185,7 @@ mod tests {
183185
);
184186

185187
let mut reader = SliceReader::new(encoded).unwrap();
186-
let field = ContextSpecific::<SetOf<Utf8StringRef<'_>, 2>>::decode_implicit(
188+
let field = ContextSpecific::<SetOfVec<Utf8StringRef<'_>>>::decode_implicit(
187189
&mut reader,
188190
TagNumber(2),
189191
)

0 commit comments

Comments
 (0)