diff options
Diffstat (limited to 'docs/source/pyasn1/type/namedtype/contents.rst')
-rw-r--r-- | docs/source/pyasn1/type/namedtype/contents.rst | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/docs/source/pyasn1/type/namedtype/contents.rst b/docs/source/pyasn1/type/namedtype/contents.rst new file mode 100644 index 0000000..2e553e6 --- /dev/null +++ b/docs/source/pyasn1/type/namedtype/contents.rst @@ -0,0 +1,40 @@ + +.. _type.namedtype: + +Fields of constructed types +--------------------------- + +The :ref:`Sequence <univ.Sequence>`, :ref:`Set <univ.Set>` and +:ref:`Choice <univ.Choice>` ASN.1 types embed other ASN.1 types +as named fields. + +Each field can be expressed via the :ref:`NamedType <namedtype.NamedType>` +object while the individual fields are brought together by the +:ref:`NamedTypes <namedtype.NamedTypes>` object. + +Ultimately, the fields get attached to the ASN.1 type's *.componentType* +attributes. + +.. code-block:: python + + class RSAPublicKey(Sequence): + """ + ASN.1 specification: + + RSAPublicKey ::= SEQUENCE { + modulus INTEGER, -- n + publicExponent INTEGER -- e + } + """ + componentType = NamedTypes( + NamedType('modulus', Integer()), + NamedType('publicExponent', Integer()) + ) + +.. toctree:: + :maxdepth: 2 + + /pyasn1/type/namedtype/namedtype + /pyasn1/type/namedtype/optionalnamedtype + /pyasn1/type/namedtype/defaultednamedtype + /pyasn1/type/namedtype/namedtypes |