When a BIT STRING has named bits, it would be really helpful to have a way to access the bits by name. But currently no code in any form is generated which maps the bit names to their integer value (or even the bit value from the bit string). A value from the bit string can only be accessed if the user knows the index from somewhere else and hard-codes it into their code.
Example
For example given this definition from ETSI TS 103 301 V2.2.1:
TEST DEFINITIONS::=
BEGIN
LaneAttributes-Vehicle ::= BIT STRING {
isVehicleRevocableLane (0),
isVehicleFlyOverLane (1),
hovLaneUseOnly (2),
restrictedToBusUse (3),
restrictedToTaxiUse (4),
restrictedFromPublicUse (5),
hasIRbeaconCoverage (6),
permissionOnRequest (7)
} (SIZE (8,...))
Test ::= SEQUENCE {
vehicle LaneAttributes-Vehicle
}
END
The compiler only produces:
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
#[rasn(delegate, identifier = "LaneAttributes-Vehicle", size("8", extensible))]
pub struct LaneAttributesVehicle(pub BitString);
Possible Interfaces
I can imagine two ways to solve this:
- Either just export the named bits as enum which can be used as a bit index in the bitvec. So a bit can be read like
vehicle[LaneAttrVehicle::restrictedToBusUse as usize]
- Or (even better) provide getter and setter methods for the individual bits
Export enum
Would need to create code like this for example:
#[repr(usize)]
#[allow(dead_code)]
#[derive(Debug, Clone, PartialEq, Eq)]
enum LaneAttributesVehicleBit {
IsVehicleRevocableLane = 0,
IsVehicleFlyOverLane = 1,
HovLaneUseOnly = 2,
RestrictedToBusUse = 3,
RestrictedToTaxiUse = 4,
RestrictedFromPublicUse = 5,
HasIrbeaconCoverage = 6,
PermissionOnRequest = 7,
}
When a
BIT STRINGhas named bits, it would be really helpful to have a way to access the bits by name. But currently no code in any form is generated which maps the bit names to their integer value (or even the bit value from the bit string). A value from the bit string can only be accessed if the user knows the index from somewhere else and hard-codes it into their code.Example
For example given this definition from ETSI TS 103 301 V2.2.1:
The compiler only produces:
Possible Interfaces
I can imagine two ways to solve this:
vehicle[LaneAttrVehicle::restrictedToBusUse as usize]Export enum
Would need to create code like this for example: