Sign in

    moonbitstack/moonrpc/proto does not have a README file

    PbError

    pub suberror PbError {
    Truncated
    BadWireType(Int)
    Overflow
    BadUtf8
    } derive(Eq)

    A raised protobuf decode failure: Truncated when the buffer ends inside a field, BadWireType for a group or unknown wire type, Overflow for a varint longer than ten octets, and BadUtf8 for an invalid string field.
    impl Show for PbError

    PbError::equal

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

    PbError::not_equal

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

    PbError::output

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

    PbError::to_string

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

    FieldDescriptor

    pub(all) struct FieldDescriptor {
    name : String
    number : Int
    label : FieldLabel
    type_ : FieldType
    type_name : String
    } derive(Eq)

    One field of a message (FieldDescriptorProto). type_name is the fully-qualified name of the referenced message or enum for TypeMessage / TypeEnum, and empty for scalars.

    FieldDescriptor::decode

    fn FieldDescriptor::decode(body : Bytes) -> FieldDescriptor raise PbError

    Decode a FieldDescriptorProto.

    FieldDescriptor::encode

    fn FieldDescriptor::encode(self : FieldDescriptor) -> Bytes

    Encode a FieldDescriptorProto.

    FieldDescriptor::equal

    FieldDescriptor::not_equal

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

    FieldDescriptor::scalar

    fn FieldDescriptor::scalar(name : String, number : Int, type_ : FieldType, label? : FieldLabel) -> FieldDescriptor

    A field with a scalar type and no composite type_name.

    FieldLabel

    pub(all) enum FieldLabel {
    LabelOptional
    LabelRequired
    LabelRepeated
    } derive(Eq)

    The FieldDescriptorProto.Label: proto3 fields are LabelOptional unless repeated.

    FieldLabel::code

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

    The descriptor.proto enum number of a label.

    FieldLabel::equal

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

    FieldLabel::from_code

    fn FieldLabel::from_code(n : Int) -> FieldLabel

    The label for a descriptor.proto enum number; anything else reads as LabelOptional.

    FieldLabel::not_equal

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

    FieldType

    pub(all) enum FieldType {
    TypeDouble
    TypeFloat
    TypeInt64
    TypeUint64
    TypeInt32
    TypeFixed64
    TypeFixed32
    TypeBool
    TypeString
    TypeMessage
    TypeBytes
    TypeUint32
    TypeEnum
    TypeSfixed32
    TypeSfixed64
    TypeSint32
    TypeSint64
    } derive(Eq)

    The FieldDescriptorProto.Type enum (proto3's scalar and composite field types). TypeGroup is intentionally absent — groups are removed from proto3.

    FieldType::code

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

    The descriptor.proto enum number of a field type.

    FieldType::equal

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

    FieldType::from_code

    fn FieldType::from_code(n : Int) -> FieldType

    The field type for a descriptor.proto enum number; an unrecognised number (including the removed group type 10) reads as TypeMessage.

    FieldType::not_equal

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

    FileDescriptor

    pub(all) struct FileDescriptor {
    name : String
    package_ : String
    messages : Array[MessageDescriptor]
    services : Array[ServiceDescriptor]
    syntax : String
    } derive(Eq)

    A single .proto file (FileDescriptorProto): its filename, package, the message and service types it defines, and the syntax level. This is the unit Server Reflection returns.

    FileDescriptor::decode

    fn FileDescriptor::decode(body : Bytes) -> FileDescriptor raise PbError

    Decode a FileDescriptorProto.

    FileDescriptor::encode

    fn FileDescriptor::encode(self : FileDescriptor) -> Bytes

    Encode a FileDescriptorProto.

    FileDescriptor::equal

    FileDescriptor::new

    fn FileDescriptor::new(name : String, package_ : String, messages? : Array[MessageDescriptor], services? : Array[ServiceDescriptor]) -> FileDescriptor

    A proto3 file with the given filename and package.

    FileDescriptor::not_equal

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

    FileDescriptor::service_names

    fn FileDescriptor::service_names(self : FileDescriptor) -> Array[String]

    The fully-qualified names of the services this file defines (package.Service).

    FileDescriptor::symbols

    fn FileDescriptor::symbols(self : FileDescriptor) -> Array[String]

    The fully-qualified names this file defines: package.Service for each service and package.Message for each message. These are the symbols a FileContainingSymbol reflection request can resolve to this file.

    MessageDescriptor

    pub(all) struct MessageDescriptor {
    name : String
    fields : Array[FieldDescriptor]
    } derive(Eq)

    A message type (DescriptorProto): its (simple) name and its fields.

    MessageDescriptor::decode

    fn MessageDescriptor::decode(body : Bytes) -> MessageDescriptor raise PbError

    Decode a DescriptorProto.

    MessageDescriptor::encode

    fn MessageDescriptor::encode(self : MessageDescriptor) -> Bytes

    Encode a DescriptorProto.

    MessageDescriptor::equal

    MessageDescriptor::not_equal

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

    MethodDescriptor

    pub(all) struct MethodDescriptor {
    name : String
    input_type : String
    output_type : String
    client_streaming : Bool
    server_streaming : Bool
    } derive(Eq)

    One RPC method (MethodDescriptorProto): its name, the fully-qualified request and response message names, and the two streaming flags that together pick the call cardinality.

    MethodDescriptor::decode

    fn MethodDescriptor::decode(body : Bytes) -> MethodDescriptor raise PbError

    Decode a MethodDescriptorProto.

    MethodDescriptor::encode

    fn MethodDescriptor::encode(self : MethodDescriptor) -> Bytes

    Encode a MethodDescriptorProto.

    MethodDescriptor::equal

    MethodDescriptor::not_equal

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

    PbReader

    pub struct PbReader {
    data : Bytes
    pos : Int
    }

    A forward cursor over an encoded protobuf message. read_tag pulls the next field's number and wire type; the typed readers then consume its body. skip discards an unknown field's body so a decoder tolerates fields it does not know (protobuf forward compatibility).

    PbReader::eof

    fn PbReader::eof(self : PbReader) -> Bool

    Whether the whole message has been consumed.

    PbReader::new

    fn PbReader::new(data : Bytes) -> PbReader

    A reader positioned at the start of data.

    PbReader::read_bool

    fn PbReader::read_bool(self : PbReader) -> Bool raise PbError

    Read a bool field body.

    PbReader::read_bytes

    fn PbReader::read_bytes(self : PbReader) -> Bytes raise PbError

    Read a bytes field body.

    PbReader::read_fixed32

    fn PbReader::read_fixed32(self : PbReader) -> UInt raise PbError

    Read a little-endian 32-bit fixed value.

    PbReader::read_fixed64

    fn PbReader::read_fixed64(self : PbReader) -> UInt64 raise PbError

    Read a little-endian 64-bit fixed value.

    PbReader::read_int32

    fn PbReader::read_int32(self : PbReader) -> Int raise PbError

    Read an int32 field body (the low 32 bits of the varint).

    PbReader::read_int64

    fn PbReader::read_int64(self : PbReader) -> Int64 raise PbError

    Read an int64 field body.

    PbReader::read_len_delim

    fn PbReader::read_len_delim(self : PbReader) -> Bytes raise PbError

    Read a length-delimited body's raw bytes.

    PbReader::read_map_string_string

    fn PbReader::read_map_string_string(self : PbReader) -> (String, String) raise PbError

    Read one map<string, string> entry (a length-delimited { key = 1, value = 2 } submessage) as (key, value). Call once the tag for the map field has been read.

    PbReader::read_packed_int32

    fn PbReader::read_packed_int32(self : PbReader) -> Array[Int] raise PbError

    Read a packed repeated int32 field: the length-delimited body decoded as back-to-back int32 varints.

    PbReader::read_sint32

    fn PbReader::read_sint32(self : PbReader) -> Int raise PbError

    Read a sint32 field body (zigzag-decoded).

    PbReader::read_sint64

    fn PbReader::read_sint64(self : PbReader) -> Int64 raise PbError

    Read a sint64 field body (zigzag-decoded).

    PbReader::read_string

    fn PbReader::read_string(self : PbReader) -> String raise PbError

    Read a string field body, decoding UTF-8. Raises BadUtf8 on invalid bytes.

    PbReader::read_tag

    fn PbReader::read_tag(self : PbReader) -> (Int, WireType) raise PbError

    Read a field tag, returning (field_number, wire_type). Raises BadWireType for a group or unknown wire type.

    PbReader::read_uint32

    fn PbReader::read_uint32(self : PbReader) -> UInt raise PbError

    Read a uint32 field body.

    PbReader::read_uint64

    fn PbReader::read_uint64(self : PbReader) -> UInt64 raise PbError

    Read a uint64 field body.

    PbReader::read_varint

    fn PbReader::read_varint(self : PbReader) -> UInt64 raise PbError

    Read a base-128 varint. Raises Overflow past ten octets and Truncated if the buffer ends mid-varint.

    PbReader::skip

    fn PbReader::skip(self : PbReader, wire : WireType) -> Unit raise PbError

    Discard the body of a field whose number the decoder does not recognise, given its wire type — the mechanism behind protobuf's forward compatibility.

    PbWriter

    pub struct PbWriter {
    buf :
    Buffer

    }

    An append-only protobuf message encoder. Field writers append a tag and the field body; to_bytes yields the finished message. Fields are written in the caller's order — protobuf places no ordering requirement on distinct fields, and a message struct's encoder writes them by ascending number by convention.

    PbWriter::bool_

    fn PbWriter::bool_(self : PbWriter, field : Int, v : Bool) -> Unit

    Write a bool field.

    PbWriter::bytes_

    fn PbWriter::bytes_(self : PbWriter, field : Int, v : Bytes) -> Unit

    Write a bytes field.

    PbWriter::enum_

    fn PbWriter::enum_(self : PbWriter, field : Int, v : Int) -> Unit

    Write an enum field (its integer value, as a varint).

    PbWriter::fixed32

    fn PbWriter::fixed32(self : PbWriter, field : Int, v : UInt) -> Unit

    Write a fixed32/sfixed32/float field.

    PbWriter::fixed64

    fn PbWriter::fixed64(self : PbWriter, field : Int, v : UInt64) -> Unit

    Write a fixed64/sfixed64/double field.

    PbWriter::int32

    fn PbWriter::int32(self : PbWriter, field : Int, v : Int) -> Unit

    Write an int32 field. Negative values sign-extend to a full ten-octet varint, exactly as the reference implementation encodes them.

    PbWriter::int64

    fn PbWriter::int64(self : PbWriter, field : Int, v : Int64) -> Unit

    Write an int64 field.

    PbWriter::map_string_string

    fn PbWriter::map_string_string(self : PbWriter, field : Int, key : String, value : String) -> Unit

    Write one map<string, string> entry for field: a length-delimited submessage { key = 1, value = 2 }, emitted once per pair (a proto map is repeated entries).

    PbWriter::message_

    fn PbWriter::message_(self : PbWriter, field : Int, v : Bytes) -> Unit

    Write an embedded-message field: the pre-encoded sub-message as a length-delimited body.

    PbWriter::new

    fn PbWriter::new() -> PbWriter

    A fresh, empty message encoder.

    PbWriter::packed_int32

    fn PbWriter::packed_int32(self : PbWriter, field : Int, values : Array[Int]) -> Unit

    Write a packed repeated int32 field: all values as back-to-back varints inside one length-delimited field (proto3's default for scalar repeated).

    PbWriter::sint32

    fn PbWriter::sint32(self : PbWriter, field : Int, v : Int) -> Unit

    Write a sint32 field (zigzag-encoded so small-magnitude negatives stay short).

    PbWriter::sint64

    fn PbWriter::sint64(self : PbWriter, field : Int, v : Int64) -> Unit

    Write a sint64 field (zigzag-encoded).

    PbWriter::string_

    fn PbWriter::string_(self : PbWriter, field : Int, v : String) -> Unit

    Write a string field (UTF-8 encoded).

    PbWriter::to_bytes

    fn PbWriter::to_bytes(self : PbWriter) -> Bytes

    The bytes written so far.

    PbWriter::uint32

    fn PbWriter::uint32(self : PbWriter, field : Int, v : UInt) -> Unit

    Write a uint32 field.

    PbWriter::uint64

    fn PbWriter::uint64(self : PbWriter, field : Int, v : UInt64) -> Unit

    Write a uint64 field.

    PbWriter::write_fixed32

    fn PbWriter::write_fixed32(self : PbWriter, v : UInt) -> Unit

    Append a little-endian 32-bit fixed value (wire type 5, no tag).

    PbWriter::write_fixed64

    fn PbWriter::write_fixed64(self : PbWriter, v : UInt64) -> Unit

    Append a little-endian 64-bit fixed value (wire type 1, no tag).

    PbWriter::write_len_delim

    fn PbWriter::write_len_delim(self : PbWriter, body : Bytes) -> Unit

    Append a length-delimited body: a varint length then the raw bytes (wire type 2, no tag).

    PbWriter::write_tag

    fn PbWriter::write_tag(self : PbWriter, field : Int, wire : WireType) -> Unit

    Append a field tag: (field_number << 3) | wire_type, itself a varint.

    PbWriter::write_varint

    fn PbWriter::write_varint(self : PbWriter, value : UInt64) -> Unit

    Append a base-128 varint (protobuf "Base 128 Varints"): seven bits per octet, little-endian groups, the high bit marking continuation.

    ServiceDescriptor

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

    A service (ServiceDescriptorProto): its (simple) name and its methods.

    ServiceDescriptor::decode

    fn ServiceDescriptor::decode(body : Bytes) -> ServiceDescriptor raise PbError

    Decode a ServiceDescriptorProto.

    ServiceDescriptor::encode

    fn ServiceDescriptor::encode(self : ServiceDescriptor) -> Bytes

    Encode a ServiceDescriptorProto.

    ServiceDescriptor::equal

    ServiceDescriptor::not_equal

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

    WireType

    pub(all) enum WireType {
    Varint
    Fixed64
    LengthDelim
    Fixed32
    } derive(Eq)

    The four protobuf wire types carried by a field tag's low three bits. The two group types (3 start-group, 4 end-group) are deprecated and unsupported, so from_code rejects them.
    impl Show for WireType

    WireType::code

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

    The wire-type number (the tag's low three bits).

    WireType::equal

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

    WireType::from_code

    fn WireType::from_code(n : Int) -> WireType?

    The wire type for a tag's low three bits, or None for the deprecated group types (3/4) and any out-of-range value.

    WireType::not_equal

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

    WireType::output

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

    WireType::to_string

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

    decode_file_descriptor_set

    fn decode_file_descriptor_set(body : Bytes) -> Array[FileDescriptor] raise PbError

    Decode a FileDescriptorSet into its files.

    encode_file_descriptor_set

    fn encode_file_descriptor_set(files : Array[FileDescriptor]) -> Bytes

    Encode a FileDescriptorSet (protoc --descriptor_set_out): the concatenation of FileDescriptorProtos under repeated field 1.