Skip to content

Commit f3bd344

Browse files
authored
Batch 2: Add data_length implementations (#554)
- Add data_length to Implicit<T, {TAG}> - Add data_length to &T (reference to SimpleAsn1Writable type) - Add data_length to Box<T> (boxed SimpleAsn1Writable type)
1 parent ec1f480 commit f3bd344

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/types.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,21 @@ impl<T: SimpleAsn1Writable> SimpleAsn1Writable for &T {
152152
fn write_data(&self, dest: &mut WriteBuf) -> WriteResult {
153153
T::write_data(self, dest)
154154
}
155+
156+
fn data_length(&self) -> Option<usize> {
157+
T::data_length(self)
158+
}
155159
}
156160

157161
impl<T: SimpleAsn1Writable> SimpleAsn1Writable for Box<T> {
158162
const TAG: Tag = T::TAG;
159163
fn write_data(&self, dest: &mut WriteBuf) -> WriteResult {
160164
T::write_data(self, dest)
161165
}
166+
167+
fn data_length(&self) -> Option<usize> {
168+
T::data_length(self)
169+
}
162170
}
163171

164172
/// A TLV (type, length, value) represented as the tag and bytes content.
@@ -1955,6 +1963,10 @@ impl<T: SimpleAsn1Writable, const TAG: u32> SimpleAsn1Writable for Implicit<T, {
19551963
fn write_data(&self, dest: &mut WriteBuf) -> WriteResult {
19561964
self.inner.write_data(dest)
19571965
}
1966+
1967+
fn data_length(&self) -> Option<usize> {
1968+
self.inner.data_length()
1969+
}
19581970
}
19591971

19601972
/// `Explicit` is a type which wraps another ASN.1 type, indicating that the tag is an ASN.1

0 commit comments

Comments
 (0)