Create |ASN.1| schema or value object. |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its objects are immutable and duck-type both Python :class:`tuple` (as a tuple of bits) and :class:`int` objects. Keyword Args ------------ value: :class:`int`, :clas
| 339 | |
| 340 | |
| 341 | class BitString(base.SimpleAsn1Type): |
| 342 | """Create |ASN.1| schema or value object. |
| 343 | |
| 344 | |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its |
| 345 | objects are immutable and duck-type both Python :class:`tuple` (as a tuple |
| 346 | of bits) and :class:`int` objects. |
| 347 | |
| 348 | Keyword Args |
| 349 | ------------ |
| 350 | value: :class:`int`, :class:`str` or |ASN.1| object |
| 351 | Python :class:`int` or :class:`str` literal representing binary |
| 352 | or hexadecimal number or sequence of integer bits or |ASN.1| object. |
| 353 | If `value` is not given, schema object will be created. |
| 354 | |
| 355 | tagSet: :py:class:`~pyasn1.type.tag.TagSet` |
| 356 | Object representing non-default ASN.1 tag(s) |
| 357 | |
| 358 | subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection` |
| 359 | Object representing non-default ASN.1 subtype constraint(s). Constraints |
| 360 | verification for |ASN.1| type occurs automatically on object |
| 361 | instantiation. |
| 362 | |
| 363 | namedValues: :py:class:`~pyasn1.type.namedval.NamedValues` |
| 364 | Object representing non-default symbolic aliases for numbers |
| 365 | |
| 366 | binValue: :py:class:`str` |
| 367 | Binary string initializer to use instead of the *value*. |
| 368 | Example: '10110011'. |
| 369 | |
| 370 | hexValue: :py:class:`str` |
| 371 | Hexadecimal string initializer to use instead of the *value*. |
| 372 | Example: 'DEADBEEF'. |
| 373 | |
| 374 | Raises |
| 375 | ------ |
| 376 | ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error |
| 377 | On constraint violation or bad initializer. |
| 378 | |
| 379 | Examples |
| 380 | -------- |
| 381 | .. code-block:: python |
| 382 | |
| 383 | class Rights(BitString): |
| 384 | ''' |
| 385 | ASN.1 specification: |
| 386 | |
| 387 | Rights ::= BIT STRING { user-read(0), user-write(1), |
| 388 | group-read(2), group-write(3), |
| 389 | other-read(4), other-write(5) } |
| 390 | |
| 391 | group1 Rights ::= { group-read, group-write } |
| 392 | group2 Rights ::= '0011'B |
| 393 | group3 Rights ::= '3'H |
| 394 | ''' |
| 395 | namedValues = NamedValues( |
| 396 | ('user-read', 0), ('user-write', 1), |
| 397 | ('group-read', 2), ('group-write', 3), |
| 398 | ('other-read', 4), ('other-write', 5) |