moonbitstack/moonproto/reflect does not have a README file

    Enum

    pub(open) trait Enum {
    fn descriptor(Self) -> EnumDescriptor
    fn enum_type(Self) -> &EnumType
    fn number(Self) -> Int
    }

    A concrete enum value.

    EnumType

    pub(open) trait EnumType {
    fn new_enum(Self, Int) -> &Enum
    fn descriptor(Self) -> EnumDescriptor
    }

    An enum's concrete type: its descriptor and a constructor.

    ExtensionType

    pub(open) trait ExtensionType {
    fn new_value(Self) -> Value
    fn zero(Self) -> Value
    fn descriptor(Self) -> FieldDescriptor
    fn is_valid_value(Self, Value) -> Bool
    }

    A concrete extension: its type and validation of a value assigned to it.

    Fresh

    pub(open) trait Fresh {
    fn fresh(Self) -> Self
    }

    A message type that can build an empty instance of its own concrete type. Kept apart from Message so that &Message stays a usable trait object.

    ListField

    pub(open) trait ListField {
    fn length(Self) -> Int
    fn get(Self, Int) -> Value
    fn set(Self, Int, Value) -> Unit
    fn append(Self, Value) -> Unit
    fn append_mutable(Self) -> Value
    fn truncate(Self, Int) -> Unit
    fn new_element(Self) -> Value
    fn is_valid(Self) -> Bool
    }

    A repeated field: zero-indexed and ordered.

    MapField

    pub(open) trait MapField {
    fn length(Self) -> Int
    fn range(Self, (MapKey, Value) -> Bool) -> Unit
    fn has(Self, MapKey) -> Bool
    fn clear(Self, MapKey) -> Unit
    fn get(Self, MapKey) -> Value
    fn set(Self, MapKey, Value) -> Unit
    fn mutable(Self, MapKey) -> Value
    fn new_value(Self) -> Value
    fn is_valid(Self) -> Bool
    }

    A map field: unordered, keyed by one of the six key kinds.

    Message

    pub(open) trait Message {
    fn descriptor(Self) -> MessageDescriptor
    fn message_type(Self) -> &MessageType
    fn is_valid(Self) -> Bool
    fn range(Self, (FieldDescriptor, Value) -> Bool) -> Unit
    fn range_extensions(Self, (FieldDescriptor, Value) -> Bool) -> Unit
    fn has(Self, FieldDescriptor) -> Bool
    fn clear(Self, FieldDescriptor) -> Unit
    fn get(Self, FieldDescriptor) -> Value
    fn set(Self, FieldDescriptor, Value) -> Unit
    fn mutable(Self, FieldDescriptor) -> Value
    fn new_field(Self, FieldDescriptor) -> Value
    fn which_oneof(Self, OneofDescriptor) -> Int?
    fn get_unknown(Self) -> RawFields
    fn set_unknown(Self, RawFields) -> Unit
    }

    A message instance, reachable only through its descriptor.

    MessageType

    pub(open) trait MessageType {
    fn new_message(Self) -> &Message
    fn zero(Self) -> &Message
    fn descriptor(Self) -> MessageDescriptor
    }

    A message's concrete type: its descriptor and a constructor.

    Refused

    pub(all) suberror Refused {
    Conflict(String)
    }

    A registry refusal: a name already taken.
    impl Show for Refused

    Refused::output

    fn Refused::output(self : Refused, logger : &Logger) -> Unit

    Refused::to_string

    fn Refused::to_string(self : Refused) -> String

    Cardinality

    pub(all) enum Cardinality {
    Optional
    Required
    Repeated
    } derive(Eq)

    Whether a field appears zero or one times, exactly once, or any number of times.

    Cardinality::code

    fn Cardinality::code(self : Cardinality) -> Int

    Cardinality::equal

    fn Cardinality::equal(Cardinality, Cardinality) -> Bool

    Cardinality::not_equal

    fn Cardinality::not_equal(x : Cardinality, y : Cardinality) -> Bool

    Cardinality::of

    fn Cardinality::of(code : Int) -> Cardinality?

    Element

    pub(all) struct Element[T] {
    to_value : (T) -> Value
    from_value : (Value) -> T
    make : () -> T
    copy_into : (T, &Message) -> Unit
    is_message : Bool
    }

    How to move one element of a repeated or map field between its typed form and a Value. copy_into exists because a message element cannot be reconstructed from a Value: the concrete type is only known here, so the value is copied into storage instead.

    Element::new

    fn[T] Element::new(to_value : (T) -> Value, from_value : (Value) -> T, make : () -> T, copy_into : (T, &Message) -> Unit, is_message : Bool) -> Element[T]

    EnumDescriptor

    pub(all) struct EnumDescriptor {
    name : String
    full_name : String
    values : Array[EnumValueDescriptor]
    closed : Bool
    file_path : String
    }

    EnumDescriptor::value_by_name

    fn EnumDescriptor::value_by_name(self : EnumDescriptor, name : String) -> EnumValueDescriptor?

    The value with name, or None.

    EnumDescriptor::value_by_number

    fn EnumDescriptor::value_by_number(self : EnumDescriptor, number : Int) -> EnumValueDescriptor?

    The value with number, or None.

    EnumValueDescriptor

    pub(all) struct EnumValueDescriptor {
    name : String
    number : Int
    full_name : String
    }

    FieldDescriptor

    pub(all) struct FieldDescriptor {
    name : String
    full_name : String
    number : Int
    kind : Kind
    cardinality : Cardinality
    json_name : String
    text_name : String
    has_presence : Bool
    is_extension : Bool
    is_map : Bool
    packed : Bool
    oneof_index : Int?
    message_type : String?
    enum_type : String?
    has_default : Bool
    default_value : Value
    default_enum_name : String?
    containing_message : String
    map_key_field : FieldDescriptor?
    map_value_field : FieldDescriptor?
    }

    FieldDescriptor::is_list

    fn FieldDescriptor::is_list(self : FieldDescriptor) -> Bool

    Whether the field is repeated and not a map, so its value is a list.

    FieldDescriptor::is_map_field

    fn FieldDescriptor::is_map_field(self : FieldDescriptor) -> Bool

    Whether the field is a map, so its value is a map rather than a list.

    FileDescriptor

    pub(all) struct FileDescriptor {
    path : String
    package_name : String
    syntax : Syntax
    messages : Array[MessageDescriptor]
    enums : Array[EnumDescriptor]
    services : Array[ServiceDescriptor]
    extensions : Array[FieldDescriptor]
    dependencies : Array[String]
    public_dependencies : Array[String]
    edition : String?
    option_map : Array[(String, Array[(String, String)])]
    }

    FileDescriptor::name

    fn FileDescriptor::name(self : FileDescriptor) -> String

    The file's own name, without directories.

    FileDescriptor::option_of

    fn FileDescriptor::option_of(self : FileDescriptor, name : String, option : String) -> String?

    The value of one option on name, if it was written.

    FileDescriptor::options_of

    fn FileDescriptor::options_of(self : FileDescriptor, name : String) -> Array[(String, String)]

    The options written on name in this file, as (name, value) pairs.

    Files

    pub struct Files {
    files : Array[FileDescriptor]
    }

    File descriptors, looked up by path or by a declaration's qualified name.

    Files::all

    fn Files::all(self : Files) -> Array[FileDescriptor]

    Files::find_enum_by_name

    fn Files::find_enum_by_name(self : Files, name : String) -> EnumDescriptor?

    Files::find_file_by_path

    fn Files::find_file_by_path(self : Files, path : String) -> FileDescriptor?

    Files::find_message_by_name

    fn Files::find_message_by_name(self : Files, name : String) -> MessageDescriptor?

    Files::length

    fn Files::length(self : Files) -> Int

    Files::new

    fn Files::new() -> Files

    Files::register

    fn Files::register(self : Files, file : FileDescriptor) -> Unit raise Refused

    Kind

    pub(all) enum Kind {
    Double
    Float
    Int64
    Uint64
    Int32
    Fixed64
    Fixed32
    Bool
    String
    Group
    Message
    Bytes
    Uint32
    Enum
    Sfixed32
    Sfixed64
    Sint32
    Sint64
    } derive(Eq)

    The eighteen field kinds, numbered as descriptor.proto numbers them.

    Kind::code

    fn Kind::code(self : Kind) -> Int

    The descriptor.proto number of the kind.

    Kind::equal

    fn Kind::equal(Kind, Kind) -> Bool

    Kind::is_enum

    fn Kind::is_enum(self : Kind) -> Bool

    Whether the kind is the enum kind.

    Kind::is_message

    fn Kind::is_message(self : Kind) -> Bool

    Whether the kind is a message or a group, and so needs a nested message.

    Kind::is_numeric

    fn Kind::is_numeric(self : Kind) -> Bool

    Whether the kind is a number, and so packable when repeated.

    Kind::not_equal

    fn Kind::not_equal(x : Kind, y : Kind) -> Bool

    Kind::of

    fn Kind::of(code : Int) -> Kind?

    The kind for a descriptor.proto number.

    MapKey

    pub(all) enum MapKey {
    Bool(Bool)
    Int32(Int)
    Int64(Int64)
    Uint32(UInt)
    Uint64(UInt64)
    String(String)
    } derive(Eq)

    A map key: the six scalar kinds a map field's key may take.

    MapKey::bool

    fn MapKey::bool(self : MapKey) -> Bool

    MapKey::equal

    fn MapKey::equal(MapKey, MapKey) -> Bool

    MapKey::int

    fn MapKey::int(self : MapKey) -> Int64

    MapKey::not_equal

    fn MapKey::not_equal(x : MapKey, y : MapKey) -> Bool

    MapKey::string

    fn MapKey::string(self : MapKey) -> String

    MapKey::uint

    fn MapKey::uint(self : MapKey) -> UInt64

    MapKey::value

    fn MapKey::value(self : MapKey) -> Value

    A value for a map key.

    MessageDescriptor

    pub(all) struct MessageDescriptor {
    name : String
    full_name : String
    syntax : Syntax
    fields : Array[FieldDescriptor]
    oneofs : Array[OneofDescriptor]
    is_map_entry : Bool
    reserved_names : Array[String]
    reserved_ranges : Array[(Int, Int)]
    required_numbers : Array[Int]
    extension_ranges : Array[(Int, Int)]
    nested_messages : Array[MessageDescriptor]
    nested_enums : Array[EnumDescriptor]
    nested_extensions : Array[FieldDescriptor]
    file_path : String
    map_key : FieldDescriptor?
    map_value : FieldDescriptor?
    }

    MessageDescriptor::field_by_json_name

    fn MessageDescriptor::field_by_json_name(self : MessageDescriptor, name : String) -> FieldDescriptor?

    The field whose JSON name is name, or None.

    MessageDescriptor::field_by_name

    fn MessageDescriptor::field_by_name(self : MessageDescriptor, name : String) -> FieldDescriptor?

    The field with the proto name, or None.

    MessageDescriptor::field_by_number

    fn MessageDescriptor::field_by_number(self : MessageDescriptor, number : Int) -> FieldDescriptor?

    The field with number, or None.

    MessageDescriptor::oneof_of_field

    fn MessageDescriptor::oneof_of_field(self : MessageDescriptor, number : Int) -> OneofDescriptor?

    The oneof that owns number, or None.

    MethodDescriptor

    pub(all) struct MethodDescriptor {
    name : String
    full_name : String
    input_type : String
    output_type : String
    streaming_client : Bool
    streaming_server : Bool
    }

    OneofDescriptor

    pub(all) struct OneofDescriptor {
    name : String
    synthetic : Bool
    field_numbers : Array[Int]
    }

    RawFields

    pub(all) struct RawFields(Bytes)

    The bytes of every unknown field a message carried, tag and body included.

    RawFields::bytes

    fn RawFields::bytes(self : RawFields) -> Bytes

    RawFields::from_bytes

    fn RawFields::from_bytes(bytes : Bytes) -> RawFields

    RawFields::is_empty

    fn RawFields::is_empty(self : RawFields) -> Bool

    RawFields::is_valid

    fn RawFields::is_valid(self : RawFields) -> Bool

    Whether the bytes are a syntactically valid sequence of fields.

    ServiceDescriptor

    pub(all) struct ServiceDescriptor {
    name : String
    full_name : String
    methods : Array[MethodDescriptor]
    file_path : String
    }

    Syntax

    pub(all) enum Syntax {
    Proto2
    Proto3
    Editions
    } derive(Eq)

    Syntax::code

    fn Syntax::code(self : Syntax) -> Int

    Syntax::equal

    fn Syntax::equal(Syntax, Syntax) -> Bool

    Syntax::not_equal

    fn Syntax::not_equal(x : Syntax, y : Syntax) -> Bool

    Syntax::of

    fn Syntax::of(code : Int) -> Syntax?

    TypedList

    pub struct TypedList[T] {
    items : Array[T]
    element : Element[T]
    }

    A repeated field backed by the array the message stores.
    impl ListField for TypedList[T]

    TypedList::append

    fn[T] TypedList::append(self : TypedList[T], value : Value) -> Unit

    TypedList::append_mutable

    fn[T] TypedList::append_mutable(self : TypedList[T]) -> Value

    TypedList::get

    fn[T] TypedList::get(self : TypedList[T], index : Int) -> Value

    TypedList::is_valid

    fn[T] TypedList::is_valid(_self : TypedList[T]) -> Bool

    TypedList::length

    fn[T] TypedList::length(self : TypedList[T]) -> Int

    TypedList::new_element

    fn[T] TypedList::new_element(self : TypedList[T]) -> Value

    TypedList::set

    fn[T] TypedList::set(self : TypedList[T], index : Int, value : Value) -> Unit

    TypedList::truncate

    fn[T] TypedList::truncate(self : TypedList[T], length : Int) -> Unit

    TypedMap

    pub struct TypedMap[K, V] {
    entries : Map[K, V]
    key_value : (K) -> MapKey
    key_of : (MapKey) -> K
    element : Element[V]
    }

    A map field backed by the map the message stores.
    impl MapField for TypedMap[K, V]

    TypedMap::clear

    fn[K : Hash + Eq, V] TypedMap::clear(self : TypedMap[K, V], key : MapKey) -> Unit

    TypedMap::get

    fn[K : Hash + Eq, V] TypedMap::get(self : TypedMap[K, V], key : MapKey) -> Value

    TypedMap::has

    fn[K : Hash + Eq, V] TypedMap::has(self : TypedMap[K, V], key : MapKey) -> Bool

    TypedMap::is_valid

    fn[K : Hash + Eq, V] TypedMap::is_valid(_self : TypedMap[K, V]) -> Bool

    TypedMap::length

    fn[K : Hash + Eq, V] TypedMap::length(self : TypedMap[K, V]) -> Int

    TypedMap::mutable

    fn[K : Hash + Eq, V] TypedMap::mutable(self : TypedMap[K, V], key : MapKey) -> Value

    TypedMap::new_value

    fn[K : Hash + Eq, V] TypedMap::new_value(self : TypedMap[K, V]) -> Value

    TypedMap::range

    fn[K : Hash + Eq, V] TypedMap::range(self : TypedMap[K, V], f : (MapKey, Value) -> Bool) -> Unit

    TypedMap::set

    fn[K : Hash + Eq, V] TypedMap::set(self : TypedMap[K, V], key : MapKey, value : Value) -> Unit

    Types

    pub struct Types {
    messages : Array[(String, &MessageType)]
    enums : Array[(String, &EnumType)]
    extensions : Array[(String, &ExtensionType)]
    extensions_by_number : Array[(String, &ExtensionType)]
    }

    Message, enum and extension types, looked up by qualified name.

    Types::find_enum_by_name

    fn Types::find_enum_by_name(self : Types, name : String) -> &EnumType?

    Types::find_extension_by_name

    fn Types::find_extension_by_name(self : Types, name : String) -> &ExtensionType?

    Types::find_extension_by_number

    fn Types::find_extension_by_number(self : Types, message : String, number : Int) -> &ExtensionType?

    Types::find_message_by_name

    fn Types::find_message_by_name(self : Types, name : String) -> &MessageType?

    Types::new

    fn Types::new() -> Types

    Types::num_enums

    fn Types::num_enums(self : Types) -> Int

    Types::num_extensions

    fn Types::num_extensions(self : Types) -> Int

    Types::num_messages

    fn Types::num_messages(self : Types) -> Int

    Types::range_enums

    fn Types::range_enums(self : Types, f : (&EnumType) -> Bool) -> Unit

    Types::range_extensions

    fn Types::range_extensions(self : Types, f : (&ExtensionType) -> Bool) -> Unit

    Types::range_messages

    fn Types::range_messages(self : Types, f : (&MessageType) -> Bool) -> Unit

    Types::register_enum

    fn Types::register_enum(self : Types, item : &EnumType) -> Unit raise Refused

    Types::register_extension

    fn Types::register_extension(self : Types, item : &ExtensionType) -> Unit raise Refused

    Types::register_message

    fn Types::register_message(self : Types, message : &MessageType) -> Unit raise Refused

    Value

    pub(all) enum Value {
    Invalid
    Bool(Bool)
    Int32(Int)
    Int64(Int64)
    Uint32(UInt)
    Uint64(UInt64)
    Float(Float)
    Double(Double)
    String(String)
    Bytes(Bytes)
    Enum(Int)
    Message(&Message)
    ListView(&ListField)
    MapView(&MapField)
    }

    One field value. A composite value holds a reference to a list, map or message, so mutation through it is visible to the message that owns it.

    Value::bool

    fn Value::bool(self : Value) -> Bool

    The value as a bool; aborts when it is not one.

    Value::bytes

    fn Value::bytes(self : Value) -> Bytes

    Value::enum_number

    fn Value::enum_number(self : Value) -> Int

    Value::equal

    fn Value::equal(self : Value, other : Value) -> Bool

    Structural equality for scalars; composites compare by identity, because semantic equality is a descriptor-driven walk in proto.equal.

    Value::float

    fn Value::float(self : Value) -> Double

    The value as a double; Float widens.

    Value::int

    fn Value::int(self : Value) -> Int64

    The value as an integer; Int32 and Int64 both widen.

    Value::is_valid

    fn Value::is_valid(self : Value) -> Bool

    Value::list

    fn Value::list(self : Value) -> &ListField

    Value::map

    fn Value::map(self : Value) -> &MapField

    Value::map_key

    fn Value::map_key(self : Value) -> MapKey?

    The value as a map key, or None when its kind cannot be a key.

    Value::message

    fn Value::message(self : Value) -> &Message

    Value::string

    fn Value::string(self : Value) -> String

    Value::uint

    fn Value::uint(self : Value) -> UInt64

    The value as an unsigned integer; Uint32 and Uint64 both widen.

    ValueList

    pub struct ValueList {
    element_kind : Kind
    element_message_type : String?
    items : Array[Value]
    }

    A list backed by an array. It remembers the element kind so that a new element can be built without consulting the descriptor again.

    ValueList::append

    fn ValueList::append(self : ValueList, value : Value) -> Unit

    ValueList::append_mutable

    fn ValueList::append_mutable(self : ValueList) -> Value

    ValueList::from_array

    fn ValueList::from_array(field : FieldDescriptor, items : Array[Value]) -> ValueList

    ValueList::get

    fn ValueList::get(self : ValueList, index : Int) -> Value

    ValueList::is_valid

    fn ValueList::is_valid(_self : ValueList) -> Bool

    ValueList::length

    fn ValueList::length(self : ValueList) -> Int

    ValueList::new

    fn ValueList::new(field : FieldDescriptor) -> ValueList

    ValueList::new_element

    fn ValueList::new_element(self : ValueList) -> Value

    ValueList::set

    fn ValueList::set(self : ValueList, index : Int, value : Value) -> Unit

    ValueList::truncate

    fn ValueList::truncate(self : ValueList, length : Int) -> Unit

    ValueMap

    pub struct ValueMap {
    key_kind : Kind
    value_kind : Kind
    value_message_type : String?
    entries : Array[(MapKey, Value)]
    }

    A map backed by an association array. Protobuf maps are usually small, and a linear lookup avoids requiring the key type to be hashable here.

    ValueMap::clear

    fn ValueMap::clear(self : ValueMap, key : MapKey) -> Unit

    ValueMap::get

    fn ValueMap::get(self : ValueMap, key : MapKey) -> Value

    ValueMap::has

    fn ValueMap::has(self : ValueMap, key : MapKey) -> Bool

    ValueMap::is_valid

    fn ValueMap::is_valid(_self : ValueMap) -> Bool

    ValueMap::length

    fn ValueMap::length(self : ValueMap) -> Int

    ValueMap::mutable

    fn ValueMap::mutable(self : ValueMap, key : MapKey) -> Value

    ValueMap::new

    fn ValueMap::new(field : FieldDescriptor) -> ValueMap

    ValueMap::new_value

    fn ValueMap::new_value(self : ValueMap) -> Value

    ValueMap::range

    fn ValueMap::range(self : ValueMap, f : (MapKey, Value) -> Bool) -> Unit

    ValueMap::set

    fn ValueMap::set(self : ValueMap, key : MapKey, value : Value) -> Unit

    assign_list

    fn[T] assign_list(target : Array[T], source : &ListField, element : Element[T]) -> Unit

    Replace the contents of target with the elements of source.

    assign_map

    fn[K : Hash + Eq, V] assign_map(target : Map[K, V], source : &MapField, key_of : (MapKey) -> K, element : Element[V]) -> Unit

    Replace the contents of target with the entries of source.

    default_for

    fn default_for(field : FieldDescriptor) -> Value

    The value get returns for a field that is unset: the declared default when there is one, the kind's zero otherwise.

    float_value

    fn float_value(value : Double) -> Value

    A 32-bit float carried as the double the wire and the encoders use.

    global_files

    let global_files : Files

    The process-wide registries a generated file registers into.

    global_types

    let global_types : Types

    invalid

    let invalid : Value

    The empty value, used where a field is absent and a Value is still required.

    is_set

    fn[T] is_set(value : T?) -> Bool

    Whether an optional field slot has a value.

    list_view

    fn[T] list_view(items : Array[T], element : Element[T]) -> &ListField

    The view a generated message returns for a repeated field.

    map_view

    fn[K : Hash + Eq, V] map_view(entries : Map[K, V], key_value : (K) -> MapKey, key_of : (MapKey) -> K, element : Element[V]) -> &MapField

    The view a generated message returns for a map field.

    message_element

    fn[T] message_element(to_value : (T) -> Value, make : () -> T, copy_into : (T, &Message) -> Unit) -> Element[T]

    The element of a repeated message field: a new element is the concrete type, and a value is copied into it.

    missing_required

    fn missing_required(message : &Message) -> String?

    The dotted path of the first required field that has no value, or None when the message and its nested messages are complete. The encoders use this so each can report the omission in its own error type.

    new_element_value

    fn new_element_value(kind : Kind, message_type : String?) -> Value

    A fresh value for an element of a list or map.

    new_field_value

    fn new_field_value(field : FieldDescriptor) -> Value

    A fresh, mutable value assignable to field: an empty list, an empty map, a new message, or the scalar default.

    parent_name

    fn parent_name(full_name : String) -> String

    The qualified name with its last segment removed.

    qualify

    fn qualify(package_name : String, name : String) -> String

    A qualified name built from a package and a short name.

    scalar_element

    fn[T] scalar_element(to_value : (T) -> Value, from_value : (Value) -> T, make : () -> T) -> Element[T]

    The element of a repeated field: a scalar converts both ways.

    short_name

    fn short_name(full_name : String) -> String

    The last segment of a qualified name.

    zero_value

    fn zero_value(kind : Kind) -> Value

    The zero value for a scalar kind; Invalid for a message or group, which has no scalar zero.