moonbitstack/moonrpc/wire does not have a README file

    StatusError

    pub(all) suberror StatusError {
    StatusError(Status, String)
    }

    The error a handler raises to answer with a status of its choosing: grpc-go's status.Error. A typed handler turns it into the call's grpc-status and grpc-message.
    impl Show for StatusError

    StatusError::output

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

    StatusError::to_string

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

    Encoding

    pub(all) enum Encoding {
    Identity
    Gzip
    Deflate
    } derive(Eq,
    Debug
    )

    A message compression the gRPC protocol names.

    Encoding::accepted

    fn Encoding::accepted(self : Encoding, accept : BytesView) -> Bool

    Whether a grpc-accept-encoding value — a comma-separated list, case-insensitive, with optional spaces — names this encoding.

    Encoding::code

    fn Encoding::code(self : Encoding) -> String

    The grpc-encoding name of this encoding.

    Encoding::decode

    fn Encoding::decode(self : Encoding, body : BytesView, limit? : Int) -> Bytes?

    Decompress body with this encoding, or None when it does not decode as one — a corrupt member, or one that expands past limit, which bounds what a compressed message can cost us (gRPC's own decompression limit).

    Encoding::encode

    fn Encoding::encode(self : Encoding, body : BytesView) -> Bytes

    Compress body with this encoding. identity is the body itself.

    Encoding::equal

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

    Encoding::not_equal

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

    Encoding::of

    fn Encoding::of(name : BytesView) -> Encoding?

    The encoding a grpc-encoding value names, or None for one we do not decode. An empty value is identity, since a call that names no encoding is not compressed.

    Encoding::to_repr

    Keepalive

    pub struct Keepalive {
    keepalive_time : Int64
    keepalive_timeout : Int64
    last_activity : Int64
    ping_outstanding : Bool
    ping_sent_at : Int64
    }

    Keepalive state for one connection: the idle threshold that triggers a PING, the ACK deadline that declares the connection dead, and the timers tracking the last activity and any in-flight PING.

    Keepalive::is_timed_out

    fn Keepalive::is_timed_out(self : Keepalive, now : Int64) -> Bool

    Whether the connection is dead at now: a PING is outstanding and its ACK has not arrived within keepalive_timeout of sending it.

    Keepalive::new

    fn Keepalive::new(keepalive_time~ : Int64, keepalive_timeout~ : Int64, now? : Int64) -> Keepalive

    A keepalive that pings after keepalive_time of idleness and gives a PING keepalive_timeout to be acknowledged. now seeds the activity clock.

    Keepalive::on_activity

    fn Keepalive::on_activity(self : Keepalive, now : Int64) -> Unit

    Record connection activity (a frame sent or received) at now, resetting the idle timer.

    Keepalive::on_ping_ack

    fn Keepalive::on_ping_ack(self : Keepalive, now : Int64) -> Unit

    Record that the PING's ACK arrived at now — the connection is alive, and this counts as activity.

    Keepalive::on_ping_sent

    fn Keepalive::on_ping_sent(self : Keepalive, now : Int64) -> Unit

    Record that a keepalive PING was sent at now.

    Keepalive::should_ping

    fn Keepalive::should_ping(self : Keepalive, now : Int64) -> Bool

    Whether a keepalive PING should be sent at now: the connection has been idle at least keepalive_time and no PING is already awaiting its ACK.

    Method

    pub(all) struct Method {
    service : String
    name : String
    }

    A fully-qualified RPC method: package.Service and the method name.

    Method::path

    fn Method::path(self : Method) -> String

    The gRPC HTTP/2 :path, i.e. /package.Service/Method.

    PingGuard

    pub(all) struct PingGuard {
    min_interval : Int64
    max_strikes : Int
    last : Int64
    strikes : Int
    }

    The guard a server keeps against a peer that pings it faster than the policy allows: a PING inside min_interval is a strike, and max_strikes of them end the connection. This is what stops a client from keeping a hundred thousand connections alive with a PING every millisecond.

    PingGuard::new

    fn PingGuard::new(min_interval~ : Int64, max_strikes~ : Int, now? : Int64) -> PingGuard

    A guard that has seen no PING yet.

    PingGuard::observe

    fn PingGuard::observe(self : PingGuard, now : Int64) -> Bool

    Record a PING at now and say whether the peer has struck out. The first PING of a connection is never a strike: last starts at the connection's own start.

    ServerKeepalive

    pub(all) struct ServerKeepalive {
    time : Int64
    timeout : Int64
    min_ping_interval : Int64
    permit_without_calls : Bool
    max_ping_strikes : Int
    }

    A server's keepalive policy (gRPC A8): time is how long an idle connection is left alone before the server pings it, timeout how long the PING may go unanswered before the connection is declared dead, min_ping_interval the shortest gap the server will tolerate between a peer's PINGs, and max_ping_strikes how many of those too-soon PINGs a peer gets before the connection is closed.

    ServerKeepalive::ping_guard

    fn ServerKeepalive::ping_guard(self : ServerKeepalive, now? : Int64) -> PingGuard

    The guard a policy implies, or None when the server takes no view on PING rate.

    Status

    pub(all) enum Status {
    Ok
    Cancelled
    Unknown
    InvalidArgument
    DeadlineExceeded
    NotFound
    AlreadyExists
    PermissionDenied
    ResourceExhausted
    FailedPrecondition
    Aborted
    OutOfRange
    Unimplemented
    Internal
    Unavailable
    DataLoss
    Unauthenticated
    } derive(Eq,
    Debug
    )

    The 17 canonical gRPC status codes (grpc-status).

    Status::code

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

    The numeric grpc-status code.

    Status::equal

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

    Status::from_h2_error

    fn Status::from_h2_error(code : Int) -> Status

    The status a call ends with when the peer resets its stream instead of sending trailers, from the RST_STREAM error code (gRPC PROTOCOL-HTTP2, "HTTP2 Error Code → Status"). A refused stream was never processed, so it is UNAVAILABLE and safe to retry; anything the table does not name is INTERNAL, since the peer broke the transport rather than the call.

    Status::from_http

    fn Status::from_http(code : Int) -> Status

    The status a non-200 HTTP response maps to when it carries no grpc-status — a proxy or a plain HTTP server answering on the gRPC port (gRPC http-grpc-status-mapping). Anything outside the table is UNKNOWN.

    Status::name

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

    The canonical uppercase status name.

    Status::not_equal

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

    Status::of

    fn Status::of(code : Int) -> Status

    The status a grpc-status code stands for; a code outside 0 to 16 is Unknown, as the gRPC status code document says a client treats it.

    Status::to_repr

    accept_encodings

    let accept_encodings : String

    The grpc-accept-encoding value this library advertises, best first: the encodings a peer may send us.

    decode_message

    fn decode_message(data : Bytes) -> (Bool, Bytes)?

    Decode one gRPC length-prefixed message from the front of data, returning (compressed, payload), or None if fewer than a full frame is present.

    default_max_frame_size

    let default_max_frame_size : Int

    The HTTP/2 default (and minimum) SETTINGS_MAX_FRAME_SIZE (RFC 7540 §6.5.2).

    default_window_size

    let default_window_size : Int

    The HTTP/2 default flow-control window and initial SETTINGS_INITIAL_WINDOW_SIZE (RFC 7540 §6.9.2): 65 535 octets.

    encode_message

    fn encode_message(payload : Bytes, compressed? : Bool) -> Bytes

    Encode a payload as a gRPC Length-Prefixed-Message: a 1-byte compression flag, a 4-byte big-endian length, then the payload. This is the framing every gRPC transport shares (gRPC-Web over HTTP/1.1 and real gRPC over HTTP/2 alike).

    is_binary_metadata

    fn is_binary_metadata(name : Bytes) -> Bool

    True when a metadata key carries binary, which gRPC spells by suffixing the key with -bin.

    max_header_list_size

    let max_header_list_size : Int

    The cap on one accumulated header block (HEADERS plus its CONTINUATION frames). Without it a peer could stream endless non-final CONTINUATION frames and grow the buffer without bound (a CONTINUATION flood); 128 KiB is far above any real gRPC request's headers.

    max_message_size

    let max_message_size : Int

    The default cap on a single received gRPC message (4 MiB, matching gRPC's default MaxRecvMsgSize). A length prefix above this — including one whose 4 bytes decode to a negative Int because the high bit is set — is rejected rather than trusted, so a hostile prefix can neither slice out of bounds nor pin unbounded buffer.

    message_len

    fn message_len(data : BytesView, at? : Int) -> Int?

    The payload length of the length-prefixed message at at, or None when fewer than the five octets of a prefix are there.

    A prefix with its high bit set reads back negative, which is how a hostile length is told from a real one before anything is sliced on it. Every reader of this framing goes through here — there are five of them across the client, the server and the socket transport, and they have to agree.

    metadata_value_from_wire

    fn metadata_value_from_wire(name : Bytes, value : Bytes) -> Bytes

    Decode a metadata value coming off the wire: base64 for a -bin key, verbatim otherwise.

    Padding is optional on the wire, and a peer may pad or not; anything outside the alphabet is skipped rather than rejected, which is what the gRPC spec asks a receiver to tolerate.

    metadata_value_to_wire

    fn metadata_value_to_wire(name : Bytes, value : Bytes) -> Bytes

    Encode a metadata value for the wire: base64 for a -bin key, verbatim otherwise.

    negotiated

    fn negotiated(server : Encoding, accept : BytesView) -> Encoding

    What to compress a reply with, given what the server wants and what the caller said it accepts: the server's encoding when the caller listed it, identity otherwise — never a body the far end would have to guess at.

    server_keepalive

    let server_keepalive : ServerKeepalive

    The policy gRPC core uses when a server sets none: two hours of idleness before a PING, twenty seconds to answer it, a PING no more often than every five minutes, and two strikes before the peer is told to calm down (ENHANCE_YOUR_CALM).

    split_messages

    fn split_messages(data : Bytes) -> Array[Bytes]

    Split a run of concatenated length-prefixed messages into their payloads, stopping at the first one that has not fully arrived.

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io