rasn/types/strings/
teletex.rs

1use super::*;
2
3use alloc::vec::Vec;
4
5/// A string, which contains the characters defined in T.61 standard.
6#[derive(Debug, Default, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
7pub struct TeletexString(Vec<u8>);
8
9impl TeletexString {
10    pub fn new(vec: Vec<u8>) -> Self {
11        Self(vec)
12    }
13}
14
15impl From<Vec<u8>> for TeletexString {
16    fn from(vec: Vec<u8>) -> Self {
17        Self::new(vec)
18    }
19}
20
21impl core::ops::Deref for TeletexString {
22    type Target = [u8];
23
24    fn deref(&self) -> &Self::Target {
25        &self.0
26    }
27}
28
29impl AsnType for TeletexString {
30    const TAG: Tag = Tag::TELETEX_STRING;
31}
32
33impl Encode for TeletexString {
34    fn encode_with_tag_and_constraints<E: Encoder>(
35        &self,
36        encoder: &mut E,
37        tag: Tag,
38        constraints: Constraints,
39    ) -> Result<(), E::Error> {
40        encoder
41            .encode_teletex_string(tag, constraints, self)
42            .map(drop)
43    }
44}
45
46impl Decode for TeletexString {
47    fn decode_with_tag_and_constraints<D: Decoder>(
48        decoder: &mut D,
49        tag: Tag,
50        constraints: Constraints,
51    ) -> Result<Self, D::Error> {
52        decoder.decode_teletex_string(tag, constraints)
53    }
54}