Skip to content

More ergonomic pattern for referencing StructDef or HashVariantDef in the protocol tree #1

Description

@johnlevidy

Today, there's not really a nice way to do this, for the example protocol:

class Bakery(Protocol):    
    PacketVariant = HashVariant[lu32]([V1.Message, V2.Message, V3.Message, V4.Message])    
    
    Packet = Struct(payload=PacketVariant
Bakery.Packet.fields['payload']

gets me the HashVariantDef

I'd like to be able to do something like

Bakery.Packet.payload.

The difficulty will probably lie in what we end up doing for variants, since today a HashVariantDef just stores a list of the underlying types.

wat(BakeryActor.Produces[0].fields['payload'].hash_types[0])

It's probable for all Variants I can have some simple getter function that gets by name? The problem is names can collide. Above, only the QName stores the full name. The type itself just calls itself "Message"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions