summaryrefslogtreecommitdiffstats
path: root/vendor/der/src/encode.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/der/src/encode.rs')
-rw-r--r--vendor/der/src/encode.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/vendor/der/src/encode.rs b/vendor/der/src/encode.rs
index d480b7bbd..28d7cba77 100644
--- a/vendor/der/src/encode.rs
+++ b/vendor/der/src/encode.rs
@@ -1,6 +1,7 @@
//! Trait definition for [`Encode`].
use crate::{Header, Length, Result, SliceWriter, Tagged, Writer};
+use core::marker::PhantomData;
#[cfg(feature = "alloc")]
use {alloc::boxed::Box, alloc::vec::Vec, core::iter};
@@ -82,6 +83,21 @@ where
}
}
+/// Dummy implementation for [`PhantomData`] which allows deriving
+/// implementations on structs with phantom fields.
+impl<T> Encode for PhantomData<T>
+where
+ T: ?Sized,
+{
+ fn encoded_len(&self) -> Result<Length> {
+ Ok(Length::ZERO)
+ }
+
+ fn encode(&self, _writer: &mut impl Writer) -> Result<()> {
+ Ok(())
+ }
+}
+
/// PEM encoding trait.
///
/// This trait is automatically impl'd for any type which impls both