Skip to main content

rasn_atn_ulcs/
lib.rs

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, size("1", extensible), identifier = "Fully-encoded-data")]
10pub struct FullyEncodedData(pub SequenceOf<PdvList>);
11
12#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
13#[rasn(choice)]
14pub enum PDVListPresentationDataValues {
15    #[rasn(tag(context, 0), identifier = "single-ASN1-type")]
16    SingleAsn1Type(Any),
17    #[rasn(tag(context, 1), identifier = "octet-aligned")]
18    OctetAligned(OctetString),
19    #[rasn(tag(context, 2))]
20    Arbitrary(BitString),
21}
22
23/// Contains one or more presentation-data-value-list (PDV-list) values
24/// ATN commentary.
25#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
26#[rasn(identifier = "PDV-list")]
27pub struct PdvList {
28    #[rasn(identifier = "transfer-syntax-name")]
29    pub transfer_syntax_name: Option<TransferSyntaxName>,
30    #[rasn(identifier = "presentation-context-identifier")]
31    pub presentation_context_identifier: PresentationContextIdentifier,
32    #[rasn(identifier = "presentation-data-values")]
33    pub presentation_data_values: PDVListPresentationDataValues,
34}
35
36impl PdvList {
37    pub fn new(
38        transfer_syntax_name: Option<TransferSyntaxName>,
39        presentation_context_identifier: PresentationContextIdentifier,
40        presentation_data_values: PDVListPresentationDataValues,
41    ) -> Self {
42        Self {
43            transfer_syntax_name,
44            presentation_context_identifier,
45            presentation_data_values,
46        }
47    }
48}
49
50/// ATN: not used for ATN Upper Layers
51#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
52#[rasn(
53    delegate,
54    value("1..=127", extensible),
55    identifier = "Presentation-context-identifier"
56)]
57pub struct PresentationContextIdentifier(pub Integer);
58
59#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
60#[rasn(delegate, identifier = "Transfer-syntax-name")]
61pub struct TransferSyntaxName(pub ObjectIdentifier);