moonbitstack/moonrpc/thrift does not have a README file

    Method

    type Method = (&Protocol) -> Unit raise ThriftError

    One method: read its arguments from the protocol, write its result fields (field 0 for a success value).

    Protocol

    pub(open) trait Protocol {
    fn reset(Self, Bytes) -> Unit
    fn output(Self) -> Bytes
    fn read_message_begin(Self) -> (String, Int, Int) raise ThriftError
    fn write_message_begin(Self, String, Int, Int) -> Unit
    fn read_struct_begin(Self) -> Unit
    fn read_struct_end(Self) -> Unit
    fn write_struct_begin(Self, String) -> Unit
    fn write_struct_end(Self) -> Unit
    fn read_field_begin(Self) -> (Int, Int) raise ThriftError
    fn write_field_begin(Self, Int, Int) -> Unit
    fn write_field_stop(Self) -> Unit
    fn read_bool(Self) -> Bool raise ThriftError
    fn read_byte(Self) -> Int raise ThriftError
    fn read_i16(Self) -> Int raise ThriftError
    fn read_i32(Self) -> Int raise ThriftError
    fn read_i64(Self) -> Int64 raise ThriftError
    fn read_double(Self) -> Double raise ThriftError
    fn read_string(Self) -> String raise ThriftError
    fn read_bytes(Self) -> Bytes raise ThriftError
    fn read_list_begin(Self) -> (Int, Int) raise ThriftError
    fn read_map_begin(Self) -> (Int, Int, Int) raise ThriftError
    fn write_bool(Self, Bool) -> Unit
    fn write_byte(Self, Int) -> Unit
    fn write_i16(Self, Int) -> Unit
    fn write_i32(Self, Int) -> Unit
    fn write_i64(Self, Int64) -> Unit
    fn write_double(Self, Double) -> Unit
    fn write_string(Self, String) -> Unit
    fn write_bytes(Self, Bytes) -> Unit
    fn write_list_begin(Self, Int, Int) -> Unit
    fn write_map_begin(Self, Int, Int, Int) -> Unit
    }

    One message's worth of reading and writing. reset points a protocol at the bytes to read and clears what it has written, so one object serves a whole connection: read a frame, write the reply, read the next frame.

    Both byte orders live behind this contract. TBinaryProtocol writes fixed-width big-endian numbers; TCompactProtocol writes zigzag varints and encodes a boolean's value inside its field header. Nothing above this trait — the processor, the client request, a service's handlers — knows which one it is talking to.

    Transport

    pub(open) trait Transport {
    async fn round_trip(Self, Bytes) -> Bytes raise ThriftError
    }

    One framed round trip: a body out, a body back. The native driver puts a length prefix on it; an in-memory transport can carry the bytes directly.

    ThriftError

    pub(all) suberror ThriftError {
    BadVersion(Int)
    Truncated
    BadType(Int)
    Depth
    Unsupported(String)
    Application(String)
    }

    impl Show for ThriftError

    ThriftError::output

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

    ThriftError::to_string

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

    Binary

    pub struct Binary {
    data : Bytes
    off : Int
    out :
    Buffer

    }

    A binary-protocol reader and writer over one message.
    impl Protocol for Binary

    Binary::eof

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

    Binary::new

    fn Binary::new(input : Bytes) -> Binary

    Binary::output

    fn Binary::output(self : Binary) -> Bytes

    Binary::read_bool

    fn Binary::read_bool(self : Binary) -> Bool raise ThriftError

    Binary::read_byte

    fn Binary::read_byte(self : Binary) -> Int raise ThriftError

    Binary::read_bytes

    fn Binary::read_bytes(self : Binary) -> Bytes raise ThriftError

    Binary::read_double

    fn Binary::read_double(self : Binary) -> Double raise ThriftError

    Binary::read_field_begin

    fn Binary::read_field_begin(self : Binary) -> (Int, Int) raise ThriftError

    Binary::read_i16

    fn Binary::read_i16(self : Binary) -> Int raise ThriftError

    Binary::read_i32

    fn Binary::read_i32(self : Binary) -> Int raise ThriftError

    Binary::read_i64

    fn Binary::read_i64(self : Binary) -> Int64 raise ThriftError

    Binary::read_list_begin

    fn Binary::read_list_begin(self : Binary) -> (Int, Int) raise ThriftError

    Binary::read_map_begin

    fn Binary::read_map_begin(self : Binary) -> (Int, Int, Int) raise ThriftError

    Binary::read_message_begin

    fn Binary::read_message_begin(self : Binary) -> (String, Int, Int) raise ThriftError

    Binary::read_string

    fn Binary::read_string(self : Binary) -> String raise ThriftError

    Binary::read_struct_begin

    fn Binary::read_struct_begin(self : Binary) -> Unit

    Binary::read_struct_end

    fn Binary::read_struct_end(self : Binary) -> Unit

    Binary::reset

    fn Binary::reset(self : Binary, input : Bytes) -> Unit

    Binary::write_bool

    fn Binary::write_bool(self : Binary, value : Bool) -> Unit

    Binary::write_byte

    fn Binary::write_byte(self : Binary, value : Int) -> Unit

    Binary::write_bytes

    fn Binary::write_bytes(self : Binary, body : Bytes) -> Unit

    Binary::write_double

    fn Binary::write_double(self : Binary, value : Double) -> Unit

    Binary::write_field_begin

    fn Binary::write_field_begin(self : Binary, type_ : Int, id : Int) -> Unit

    Binary::write_field_stop

    fn Binary::write_field_stop(self : Binary) -> Unit

    Binary::write_i16

    fn Binary::write_i16(self : Binary, value : Int) -> Unit

    Binary::write_i32

    fn Binary::write_i32(self : Binary, value : Int) -> Unit

    Binary::write_i64

    fn Binary::write_i64(self : Binary, value : Int64) -> Unit

    Binary::write_list_begin

    fn Binary::write_list_begin(self : Binary, elem : Int, size : Int) -> Unit

    Binary::write_map_begin

    fn Binary::write_map_begin(self : Binary, key : Int, value : Int, size : Int) -> Unit

    Binary::write_message_begin

    fn Binary::write_message_begin(self : Binary, name : String, kind : Int, seqid : Int) -> Unit

    Binary::write_string

    fn Binary::write_string(self : Binary, value : String) -> Unit

    Binary::write_struct_begin

    fn Binary::write_struct_begin(self : Binary, name : String) -> Unit

    Binary::write_struct_end

    fn Binary::write_struct_end(self : Binary) -> Unit

    Compact

    pub struct Compact {
    data : Bytes
    off : Int
    out :
    Buffer

    last_field : Int
    field_stack : Array[Int]
    pending_field : Bool
    pending_id : Int
    bool_value : Bool
    bool_ready : Bool
    }

    A compact-protocol reader and writer over one message.
    impl Protocol for Compact

    Compact::new

    fn Compact::new(input : Bytes) -> Compact

    Compact::output

    fn Compact::output(self : Compact) -> Bytes

    Compact::read_bool

    fn Compact::read_bool(self : Compact) -> Bool raise ThriftError

    Compact::read_byte

    fn Compact::read_byte(self : Compact) -> Int raise ThriftError

    Compact::read_bytes

    fn Compact::read_bytes(self : Compact) -> Bytes raise ThriftError

    Compact::read_double

    fn Compact::read_double(self : Compact) -> Double raise ThriftError

    Compact::read_field_begin

    fn Compact::read_field_begin(self : Compact) -> (Int, Int) raise ThriftError

    Compact::read_i16

    fn Compact::read_i16(self : Compact) -> Int raise ThriftError

    Compact::read_i32

    fn Compact::read_i32(self : Compact) -> Int raise ThriftError

    Compact::read_i64

    fn Compact::read_i64(self : Compact) -> Int64 raise ThriftError

    Compact::read_list_begin

    fn Compact::read_list_begin(self : Compact) -> (Int, Int) raise ThriftError

    Compact::read_map_begin

    fn Compact::read_map_begin(self : Compact) -> (Int, Int, Int) raise ThriftError

    Compact::read_message_begin

    fn Compact::read_message_begin(self : Compact) -> (String, Int, Int) raise ThriftError

    Compact::read_string

    fn Compact::read_string(self : Compact) -> String raise ThriftError

    Compact::read_struct_begin

    fn Compact::read_struct_begin(self : Compact) -> Unit

    Compact::read_struct_end

    fn Compact::read_struct_end(self : Compact) -> Unit

    Compact::reset

    fn Compact::reset(self : Compact, input : Bytes) -> Unit

    Compact::write_bool

    fn Compact::write_bool(self : Compact, value : Bool) -> Unit

    Compact::write_byte

    fn Compact::write_byte(self : Compact, value : Int) -> Unit

    Compact::write_bytes

    fn Compact::write_bytes(self : Compact, body : Bytes) -> Unit

    Compact::write_double

    fn Compact::write_double(self : Compact, value : Double) -> Unit

    Compact::write_field_begin

    fn Compact::write_field_begin(self : Compact, type_ : Int, id : Int) -> Unit

    Compact::write_field_stop

    fn Compact::write_field_stop(self : Compact) -> Unit

    Compact::write_i16

    fn Compact::write_i16(self : Compact, value : Int) -> Unit

    Compact::write_i32

    fn Compact::write_i32(self : Compact, value : Int) -> Unit

    Compact::write_i64

    fn Compact::write_i64(self : Compact, value : Int64) -> Unit

    Compact::write_list_begin

    fn Compact::write_list_begin(self : Compact, elem : Int, size : Int) -> Unit

    Compact::write_map_begin

    fn Compact::write_map_begin(self : Compact, key : Int, value : Int, size : Int) -> Unit

    Compact::write_message_begin

    fn Compact::write_message_begin(self : Compact, name : String, kind : Int, seqid : Int) -> Unit

    Compact::write_string

    fn Compact::write_string(self : Compact, value : String) -> Unit

    Compact::write_struct_begin

    fn Compact::write_struct_begin(self : Compact, name : String) -> Unit

    Compact::write_struct_end

    fn Compact::write_struct_end(self : Compact) -> Unit

    Processor

    pub(all) struct Processor {
    methods : Map[String, (&Protocol) -> Unit raise ThriftError]
    }

    A dispatcher over method names, one Method each.

    Processor::add

    fn Processor::add(self : Processor, name : String, handler : (&Protocol) -> Unit raise ThriftError) -> Unit

    Register handler under name, the Thrift method name on the wire.

    Processor::new

    fn Processor::new() -> Processor

    Processor::process

    fn Processor::process(self : Processor, proto : &Protocol, frame : Bytes) -> Bytes raise ThriftError

    Answer one CALL frame. A method that is not registered gets a TApplicationException with UNKNOWN_METHOD, as Apache Thrift's processors do. A ONEWAY call is run and answered with no bytes.

    call

    async fn[T : Transport, R] call(transport : T, proto : &Protocol, name : String, seqid : Int, args : (&Protocol) -> Unit raise ThriftError, read : (&Protocol) -> R raise ThriftError) -> R raise ThriftError

    Send one CALL and decode its success value with read.

    call_result

    async fn[T : Transport, R, E] call_result(transport : T, proto : &Protocol, name : String, seqid : Int, args : (&Protocol) -> Unit raise ThriftError, read : (&Protocol) -> R raise ThriftError, exception : (&Protocol, Int) -> E? raise ThriftError) -> Result[R, E] raise ThriftError

    Send one CALL and read a result that may be a declared exception.

    call_result_unit

    async fn[T : Transport, E] call_result_unit(transport : T, proto : &Protocol, name : String, seqid : Int, args : (&Protocol) -> Unit raise ThriftError, exception : (&Protocol, Int) -> E? raise ThriftError) -> Result[Unit, E] raise ThriftError

    The same, for a method that returns nothing and may still throw.

    frame

    fn frame(body : Bytes) -> Bytes

    A length-prefixed frame, as TFramedTransport writes it.

    frame_len

    fn frame_len(header : Bytes) -> Int raise ThriftError

    The body length a frame header announces.

    max_depth

    let max_depth : Int

    The largest nesting skip will follow before giving up.

    max_frame

    let max_frame : Int

    The largest framed body this library will accept, in octets.

    message_call

    let message_call : Int

    message_exception

    let message_exception : Int

    message_oneway

    let message_oneway : Int

    message_reply

    let message_reply : Int

    read_result

    fn[R, E] read_result(proto : &Protocol, read : (&Protocol) -> R raise ThriftError, exception : (&Protocol, Int) -> E? raise ThriftError) -> Result[R, E] raise ThriftError

    Read a result struct whose method declares exceptions: field 0 is the success value, any other field is a failure that exception decodes by its field id. The decoder answers None for a field it does not know and must not have read it; that one is skipped and raised as Application, so a failure nobody declared is not swallowed as a value.

    read_result_unit

    fn[E] read_result_unit(proto : &Protocol, exception : (&Protocol, Int) -> E? raise ThriftError) -> Result[Unit, E] raise ThriftError

    The same, for a method that answers nothing: an empty result struct is success.

    read_success

    fn[R] read_success(proto : &Protocol, read : (&Protocol) -> R raise ThriftError) -> R raise ThriftError

    Read a result struct: field 0 is the success value; any other field is an exception, whose string message (when it has one) is raised.

    request

    async fn[T : Transport] request(transport : T, proto : &Protocol, name : String, seqid : Int, args : (&Protocol) -> Unit raise ThriftError) -> Unit raise ThriftError

    Send one CALL and leave proto positioned inside its result struct.
    fn skip(proto : &Protocol, type_ : Int) -> Unit raise ThriftError

    Walk past one value of type_, whatever it contains.

    type_bool

    let type_bool : Int

    type_byte

    let type_byte : Int

    type_double

    let type_double : Int

    type_i16

    let type_i16 : Int

    type_i32

    let type_i32 : Int

    type_i64

    let type_i64 : Int

    type_list

    let type_list : Int

    type_map

    let type_map : Int

    type_set

    let type_set : Int

    type_stop

    let type_stop : Int

    type_string

    let type_string : Int

    type_struct

    let type_struct : Int