1#![doc = include_str!("../README.md")]
2#![no_std]
3
4extern crate alloc;
5
6use rasn::prelude::*;
7
8#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
9#[rasn(delegate, identifier = "AlgorithmID-ShortForm")]
10pub struct AlgorithmIdShortForm(pub Integer);
11
12#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
13#[rasn(delegate)]
14pub struct CompressedContent(pub OctetString);
15
16#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
17#[rasn(choice)]
18pub enum CompressedContentInfoContentType {
19 #[rasn(tag(context, 0), identifier = "contentType-ShortForm")]
20 ContentTypeShortForm(ContentTypeShortForm),
21 #[rasn(tag(context, 1), identifier = "contentType-OID")]
22 ContentTypeOid(ObjectIdentifier),
23}
24
25#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
26pub struct CompressedContentInfo {
27 #[rasn(identifier = "contentType")]
28 pub content_type: CompressedContentInfoContentType,
29 #[rasn(tag(explicit(context, 0)), identifier = "compressedContent")]
30 pub compressed_content: CompressedContent,
31}
32
33impl CompressedContentInfo {
34 pub fn new(
35 content_type: CompressedContentInfoContentType,
36 compressed_content: CompressedContent,
37 ) -> Self {
38 Self {
39 content_type,
40 compressed_content,
41 }
42 }
43}
44#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
45pub struct CompressedData {
46 #[rasn(identifier = "compressionAlgorithm")]
47 pub compression_algorithm: CompressionAlgorithmIdentifier,
48 #[rasn(identifier = "compressedContentInfo")]
49 pub compressed_content_info: CompressedContentInfo,
50}
51impl CompressedData {
52 pub fn new(
53 compression_algorithm: CompressionAlgorithmIdentifier,
54 compressed_content_info: CompressedContentInfo,
55 ) -> Self {
56 Self {
57 compression_algorithm,
58 compressed_content_info,
59 }
60 }
61}
62
63#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
64#[rasn(choice)]
65pub enum CompressionAlgorithmIdentifier {
66 #[rasn(tag(context, 0), identifier = "algorithmID-ShortForm")]
67 AlgorithmIdShortForm(AlgorithmIdShortForm),
68 #[rasn(tag(context, 1), identifier = "algorithmID-OID")]
69 AlgorithmIdOid(ObjectIdentifier),
70}
71
72#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
73#[rasn(delegate, identifier = "ContentType-ShortForm")]
74pub struct ContentTypeShortForm(pub Integer);