class Node(enc.TlvModel): id = enc.UintField(TypeNumber.NODE_ID) parent = enc.UintField(TypeNumber.PARENT_ID) rule_name = enc.RepeatedField(enc.BytesField(TypeNumber.IDENTIFIER, is_string=True)) v_edges = enc.RepeatedField(enc.ModelField(TypeNumber.VALUE_EDGE, ValueEdge)) p_edges = enc.RepeatedField(enc.ModelField(TypeNumber.PATTERN_EDGE, PatternEdge)) sign_cons = enc.RepeatedField(enc.UintField(TypeNumber.KEY_NODE_ID))
class ConstraintOption(enc.TlvModel): # Equal to a given NameComponent value value = enc.BytesField(TypeNumber.COMPONENT_VALUE) # Equal to another pattern tag = enc.UintField(TypeNumber.PATTERN_TAG) # Decide by a user function call fn = enc.ModelField(TypeNumber.USER_FN_CALL, UserFnCall)
class RefInfo(enc.TlvModel): ref_name = enc.BytesField(0x03) ref_head = enc.BytesField(0x04)
class SyncObject(enc.TlvModel): obj_type = enc.BytesField(0x01) obj_data = enc.BytesField(0x02)
class AddUserReq(enc.TlvModel): full_name = enc.BytesField(0x07) email = enc.BytesField(0x08) cert = enc.BytesField(0x09)
class TagSymbol(enc.TlvModel): tag = enc.UintField(TypeNumber.PATTERN_TAG) ident = enc.BytesField(TypeNumber.IDENTIFIER, is_string=True)
class ValueEdge(enc.TlvModel): dest = enc.UintField(TypeNumber.NODE_ID) value = enc.BytesField(TypeNumber.COMPONENT_VALUE)
class UserFnCall(enc.TlvModel): fn_id = enc.BytesField(TypeNumber.USER_FN_ID, is_string=True) args = enc.RepeatedField(enc.ModelField(TypeNumber.FN_ARGS, UserFnArg))
class UserFnArg(enc.TlvModel): # A given component value = enc.BytesField(TypeNumber.COMPONENT_VALUE) # Referring to a previous matched pattern tag = enc.UintField(TypeNumber.PATTERN_TAG)