signalr

    ASP.NET Core SignalR hub protocol, payload codecs, server and client for MoonBit

    Download zip
    Author
    Version
    0.14.0
    License
    Apache-2.0
    Last updated
    7 hours ago
    Downloads
    17

    No dependencies

    #moonrockz/signalr

    Wire compatibility with the ASP.NET Core SignalR hub protocol for MoonBit. A MoonBit program can talk to SignalR clients and servers in .NET, browsers, Node.js and Bun, and they can talk to it.

    This library is not affiliated with Microsoft. ASP.NET Core and SignalR are products of Microsoft.

    The module imports no Moon-Lander module. The framework integration (addressing, groups, connection actors and a hosted service) is in the optional module moonrockz/moon-lander-hubs.

    New to SignalR? Build a chat with the SignalR guides. This page is the reference.

    PackageTargetsContents
    moonrockz/signalrwasm, wasm-gc, js, nativeDomain types, HubValue, Codec[T], hub messages, JSON reader and writer, framing, handshake, negotiate payloads, the protocol state machine, HubMethod, ClientMethod, HubContract
    moonrockz/signalr/servernative, wasmThe hub server: negotiate, the WebSocket transport, keep-alive, timeouts, the message size limit and the graceful drain
    moonrockz/signalr/clientnative, jsThe typed client; see its guide

    #Domain types

    Each identifier of the protocol is a type with a smart constructor. A parse failure raises IdentifierError::InvalidIdentifier with the kind, the text and the broken rule, so a caller can match the rule:

    TypeRules
    HubNameASCII letter first, then letters, digits, - and _; 1 to 128 characters
    MethodName1 to 128 characters, no control or space characters
    InvocationId, StreamId1 to 128 characters, no control characters
    ConnectionId, ConnectionToken1 to 256 characters, no control or space characters
    UserId, GroupName1 to 256 characters, no control characters
    EndpointPath/ first, nonempty segments of ASCII letters, digits, -, ., _ and ~

    ///|
    test "parse identifiers and match a failure by its rule" {
    let path = @signalr.EndpointPath::parse("/chat")
    assert_eq(path.negotiate(), "/chat/negotiate")
    let rule = try {
    ignore(@signalr.EndpointPath::parse("chat"))
    None
    } catch {
    InvalidIdentifier(rule~, ..) => Some(rule)
    }
    assert_true(rule is Some(NoLeadingSlash))
    }

    A ConnectionToken never shows its text. Show, Debug and parse errors write [REDACTED]. Only the transport request that needs the token reads it with expose:

    ///|
    test "a connection token is redacted" {
    let token = @signalr.ConnectionToken::parse("x7Kq2")
    assert_eq("token \{token}", "token [REDACTED]")
    assert_eq(token.expose(), "x7Kq2")
    }

    #Payload values

    Arguments, stream items and results pass through HubValue, a tree that each hub protocol encoding can write completely: null, boolean, 64-bit integers, finite doubles, strings, bytes, timestamps, arrays and maps. A HubMap keeps its keys in the order in which they were added, and each key comes one time:

    ///|
    test "a map keeps its key order and rejects a duplicate key" {
    let map = @signalr.HubMap::empty().add("b", Int(1L)).add("a", Int(2L))
    assert_eq(map.keys(), ["b", "a"])
    let duplicate = try {
    ignore(map.add("b", Null))
    false
    } catch {
    DuplicateKey(key~) => key == "b"
    _ => false
    }
    assert_true(duplicate)
    }

    A Timestamp is an instant in UTC with a precision of 100 nanoseconds, in the range of .NET DateTime. It reads RFC 3339 text with Z or an offset, and it writes UTC text.

    #Codecs

    A Codec[T] encodes a value of T to a HubValue and decodes it back. Build codecs from the scalar codecs and the combinators. The defaults match the System.Text.Json settings that ASP.NET Core SignalR uses:

    ValueDefaultExplicit choice
    Record property namescamelCase (user_name gives userName, URLValue gives urlValue); only ASCII letters changefield(..., property="name")
    Enumsnumbers (enumeration, or enum_numbers with an EnumMapping)text (enum_names with an EnumMapping)
    BytesBase64 text in JSON
    TimestampsISO 8601 text in JSON
    64-bit integersnumbers from -(2^53 - 1) to 2^53 - 1 (int64, uint64)text (int64_as_text, uint64_as_text)

    Decode reads record property names with no regard to case, ignores properties that it does not know, and gives None for a missing option property.

    #Domain types in payloads

    Codec::parse runs the smart constructor of a domain type, so decoding is the one place where raw input becomes a domain value. An error of the constructor becomes CodecError::Rejected with the path of the value and that error:

    ///|
    test "decode a domain type through its smart constructor" {
    let user : @signalr.Codec[@signalr.UserId] = @signalr.string().parse(
    @signalr.UserId::parse,
    id => id.to_string(),
    )
    let args = @signalr.tuple2(user, @signalr.string())
    let (id, text) = args.decode(
    @signalr.HubValue::array([String("ana"), String("hi")]),
    )
    assert_eq(id.to_string(), "ana")
    assert_eq(text, "hi")
    let path = try {
    ignore(
    args.decode(
    @signalr.HubValue::array([String(""), String("hi")]),
    path=@signalr.Path::named("arguments"),
    ),
    )
    ""
    } catch {
    Rejected(path~, ..) => path.to_string()
    _ => "other error"
    }
    assert_eq(path, "arguments[0]")
    }

    #Records

    A record codec takes the constructor and one field for each property. The constructor can be a smart constructor that raises:

    ///|
    struct Reading {
    sensor_name : String
    level : Int32
    taken_at : @signalr.Timestamp
    }

    ///|
    test "a record codec writes camelCase properties" {
    let codec = @signalr.record3(
    (sensor_name, level, taken_at) => { sensor_name, level, taken_at, },
    @signalr.field("sensor_name", @signalr.string(), r => r.sensor_name),
    @signalr.field("level", @signalr.int(), r => r.level),
    @signalr.field("taken_at", @signalr.timestamp(), r => r.taken_at),
    )
    let reading = {
    sensor_name: "north",
    level: 3,
    taken_at: @signalr.Timestamp::parse("2026-12-01T10:15:00Z"),
    }
    guard codec.encode(reading) is Map(map) else { fail("expected an object") }
    assert_eq(map.keys(), ["sensorName", "level", "takenAt"])
    let back = codec.decode(Map(map))
    assert_eq(back.sensor_name, "north")
    assert_eq(back.level, 3)
    }

    #Safe integers

    JavaScript numbers hold integers exactly only up to 2^53 - 1. The default 64-bit codecs reject a larger value when they encode or decode. Select the text codec for the full range:

    ///|
    test "64-bit integers stay in the safe range unless they are text" {
    let outside = try {
    ignore(@signalr.int64().encode(9007199254740992L))
    ""
    } catch {
    IntegerOutOfRange(min~, max~, ..) => "\{min} to \{max}"
    _ => "other error"
    }
    assert_eq(outside, "-9007199254740991 to 9007199254740991")
    assert_eq(
    @signalr.int64_as_text().encode(9007199254740992L),
    String("9007199254740992"),
    )
    }

    An integer codec does not round: it rejects a number with a fraction, and it reads 1e2 as 100.

    #Protocol core

    The protocol core does no I/O. A ProtocolState takes one input (the text of a transport frame, or a local call) and gives the next state and a list of outputs: text to send, a call for the hub, a stream item or a Completion for a waiting caller, or a close. The server, the client and the tests run the same state machine.

    text in local call / cancel / item / completion | | v v +--------------------------------------------+ | ProtocolState (framing buffer, handshake, | | open calls, open streams, used IDs) | +--------------------------------------------+ | | | Send(text) Dispatch(call) Completed / ItemReceived / Closed

    The state machine applies the invocation rules. A peer that breaks one gets a Close message that names the fault, and the connection ends. Examples: an invocation ID that is in use, a Completion for an unknown ID, a result after stream items, or an ID with more than 128 characters. A program fault, such as a stream item for a call that is not a stream, raises UsageError.

    #A typed contract

    A HubContract holds the hub methods that clients call and the client methods that the hub calls. args0 to args4 give the positional arguments of a method; a call with another number of arguments fails with both numbers. Method names are unique in each direction and case-sensitive. check_call gives the method of a call, or an error text for an unknown method or a call of the wrong kind.

    #An exchange with no socket

    A MemoryPair connects a client state machine to a server state machine in memory. This example runs the handshake, one invocation and its result on all four targets with no event loop:

    ///|
    test "invoke a hub method through the in-memory pair" {
    let add : @signalr.HubMethod[(Int32, Int32), Int32] = @signalr.HubMethod::call(
    @signalr.MethodName::parse("add"),
    @signalr.args2(@signalr.int(), @signalr.int()),
    @signalr.int(),
    )
    let contract = @signalr.HubContract::new(@signalr.HubName::parse("calc")).server(
    add,
    )
    let (pair, _) = @signalr.MemoryPair::connect()
    // The client calls add(2, 3).
    let (pair, _, events) = pair.client_call(
    Blocking,
    add.name(),
    add.arguments().encode((2, 3)),
    )
    guard events is [{ role: Server, output: Dispatch(call), }] else {
    fail("expected one call on the server")
    }
    guard contract.check_call(call) is Ok(_) else {
    fail("expected a known method")
    }
    guard call.invocation_id is Some(id) else { fail("expected an ID") }
    // The hub decodes the arguments and sends the result.
    let (a, b) = add.arguments().decode(call.arguments)
    let (_, events) = pair.on_server(state => {
    state.complete(id, Result(add.result().encode(a + b)))
    })
    guard events is [{ role: Client, output: Completed(_, Result(value)), }] else {
    fail("expected the result on the client")
    }
    assert_eq(add.result().decode(value), 5)
    }

    #Messages, handshake and negotiate

    HubMessage::parse reads the seven message types of the JSON hub protocol strictly: a missing required field, a field of the wrong type and an unknown field are errors. headers is accepted on each type except Ping. HubMessage::to_frame writes the text with the record separator 0x1E. FrameBuffer cuts frames into messages and keeps an incomplete message until the rest arrives.

    HandshakeRequest, HandshakeResponse and NegotiateResponse read and write the handshake and the negotiate payloads. The negotiate reader ignores properties that it does not know. A negotiate response of version 1 holds a ConnectionToken; version 0 has no token, so a client connects with the connection ID. The debug view of a negotiate result never shows the token.

    #Server

    moonrockz/signalr/server serves one hub on moonbitlang/core/async HTTP and WebSocket, on native and on wasm under Moonrun. Stock SignalR clients connect to it: @microsoft/signalr 10.x and 11.x and the .NET client.

    POST /calc/negotiate?negotiateVersion=1 -> connectionId, connectionToken, WebSockets GET /calc?id=<connectionToken> (upgrade) -> WebSocket, then the handshake

    A HubService holds the contract and the handlers. invoke runs a call with one result; stream sends the items of a streaming call. A handler that raises HubError sends its text to the caller. Another error sends the text An unexpected error occurred invoking '<method>' on the server., and the error text is added only when ServerOptions turns on detailed errors.

    ///|
    async fn main {
    let add : @signalr.HubMethod[(Int32, Int32), Int32] = @signalr.HubMethod::call(
    @signalr.MethodName::parse("add"),
    @signalr.args2(@signalr.int(), @signalr.int()),
    @signalr.int(),
    )
    let contract = @signalr.HubContract::new(@signalr.HubName::parse("calc")).server(
    add,
    )
    let service = @server.HubService::new(contract, invoke=(_, call) => {
    let (a, b) = add.arguments().decode(call.arguments)
    Some(add.result().encode(a + b))
    })
    let options = @server.ServerOptions::new(
    @signalr.EndpointPath::parse("/calc"),
    )
    let server = @server.Server::bind(
    @server.BindAddress::parse("127.0.0.1:5000"),
    options,
    service,
    )
    server.run()
    }

    The program tests/signalr-calc-server is a full example with a stream.

    OptionDefaultEffect
    keep_alive15 sSend a Ping when the server sent nothing for this time
    client_timeout30 sClose a connection that sent nothing for this time
    handshake_timeout15 sClose a WebSocket with no complete handshake in this time
    negotiate_timeout15 sRemove a negotiated connection that gets no WebSocket in this time
    max_message_size32768 bytesClose a connection that sends a larger hub message
    outgoing_messages128End a connection with the cause SlowClient when this many calls to the client wait
    parallel_calls1The calls of one connection that run at the same time; a stream to the client frees its place when it starts
    max_connections1000The TCP connections at the same time; more wait
    clockthe platformThe time of each limit; a test gives its own clock
    detailed_errorsoffPut the error text in Completion errors
    admiteach requestSee each request first, for the hub and for other paths; Deny gives the status 403
    fallbacknone, the status 404Answer each request for a path that is not of the hub, for example with a web page

    With fallback, one server gives a web page and its hub one origin. A WebSocket has no CORS check, so admit is the place to refuse a page of another origin. The client guide has an example of the two.

    The calls of one connection run in the order of arrival, one at a time, after the connect handler. Upload items wait for their handler: when it reads slowly, the server reads the client slowly, as ASP.NET Core does. A client can leave at most 1024 upload streams open. Connection::send calls a client method with no wait; Connection::invoke waits for the result of the client. A stream handler waits when the client reads slowly.

    The timers are the pure value KeepAlive, which takes the time as an input. The server and the client get the time from a Clock, so a test moves a whole server by 30 seconds with no wait. Server::stop refuses new connections and calls, waits for the open calls until the drain time limit, sends a Close message to each connection and gives a DrainReport with the number of calls that it cancelled. A client that reads nothing cannot hold the stop: its connection ends about a second after the limit. The Close message has no error and permits a reconnect, so a client with automatic reconnect comes back after a restart.

    #Under Moonrun with a policy

    The server needs only a bind permission. This experimental Moonrun policy permits a bind to one address and nothing else:

    { "net": { "bind": ["127.0.0.1:5187"] } }

    Build the wasm program and run it with the policy:

    moon build tests/signalr-calc-server --target wasm moonrun --policy policy.json \ _build/wasm/debug/build/moonrockz/moon-lander-tests/signalr-calc-server/signalr-calc-server.wasm \ 127.0.0.1:5187

    moonx --experimental-policy policy.json <package> runs a published package with the same runtime and policy engine. A bind that the policy does not permit fails with ServerError::BindFailed, which names the address. mise run check:signalr-smoke reads this policy from this page, runs this command with it, and calls the server with the stock JavaScript client.

    AuthRejected

    pub(all) suberror AuthRejected {
    AuthRejected(String)
    } derive(Eq,
    Debug
    )

    The refusal of an authenticator. The reason is for the log of the server; the client gets only the status 401.

    AuthRejected::equal

    automatically derived

    AuthRejected::not_equal

    fn AuthRejected::not_equal(x : AuthRejected, y : AuthRejected) -> Bool
    automatically derived

    AuthRejected::to_repr

    automatically derived

    CodecError

    pub suberror CodecError {
    TypeMismatch(path~ : Path, expected~ : ValueKind, found~ : ValueKind)
    LengthMismatch(path~ : Path, expected~ : Int, found~ : Int)
    MissingProperty(path~ : Path, name~ : String)
    NotAnInteger(path~ : Path, value~ : Double)
    IntegerOutOfRange(path~ : Path, value~ : String, min~ : String, max~ : String)
    NotFinite(path~ : Path, value~ : Double)
    UnknownEnumValue(path~ : Path, value~ : String)
    InvalidText(path~ : Path, format~ : TextFormat, text~ : String)
    NullInOption(path~ : Path)
    Rejected(path~ : Path, cause~ : Error)
    } derive(
    Debug
    )

    A fault when a codec encodes or decodes a payload value. Each case holds the path to the failed value.

    CodecError::message

    fn CodecError::message(self : CodecError) -> String

    Text for people that describes the fault.

    CodecError::path

    fn CodecError::path(self : CodecError) -> Path

    The path to the failed value.

    CodecError::to_repr

    automatically derived

    ContractError

    pub suberror ContractError {
    DuplicateHubMethod(MethodName)
    DuplicateClientMethod(MethodName)
    } derive(Eq,
    Debug
    )

    A fault in a hub contract.

    ContractError::equal

    automatically derived

    ContractError::message

    fn ContractError::message(self : ContractError) -> String

    Text for people that describes the fault.

    ContractError::not_equal

    fn ContractError::not_equal(x : ContractError, y : ContractError) -> Bool
    automatically derived

    ContractError::to_repr

    automatically derived

    EnumMappingError

    pub suberror EnumMappingError {
    AmbiguousValue(value~ : String)
    } derive(Eq,
    Debug
    )

    Two different cases of an enum have the same wire value, so a decode could not give back the encoded case.

    EnumMappingError::equal

    automatically derived

    EnumMappingError::message

    fn EnumMappingError::message(self : EnumMappingError) -> String

    Text for people that describes the fault.

    EnumMappingError::not_equal

    fn EnumMappingError::not_equal(x : EnumMappingError, y : EnumMappingError) -> Bool
    automatically derived

    EnumMappingError::to_repr

    automatically derived

    HubError

    pub(all) suberror HubError {
    HubError(String)
    } derive(Eq,
    Debug
    )

    An error that a hub method raises to send its text to the caller. The Completion error holds the text as it is, also when detailed errors are off, as a HubException does in ASP.NET Core.
    impl Show for HubError

    HubError::equal

    fn HubError::equal(HubError, HubError) -> Bool
    automatically derived

    HubError::not_equal

    fn HubError::not_equal(x : HubError, y : HubError) -> Bool
    automatically derived

    HubError::output

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

    HubError::to_repr

    automatically derived

    HubError::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    HubValueError

    pub suberror HubValueError {
    DuplicateKey(key~ : String)
    NotFinite(value~ : Double)
    } derive(Eq,
    Debug
    )

    A fault in the construction of a payload value.

    HubValueError::equal

    automatically derived

    HubValueError::message

    fn HubValueError::message(self : HubValueError) -> String

    Text for people that describes the fault.

    HubValueError::not_equal

    fn HubValueError::not_equal(x : HubValueError, y : HubValueError) -> Bool
    automatically derived

    HubValueError::to_repr

    automatically derived

    IdentifierError

    pub suberror IdentifierError {
    InvalidIdentifier(kind~ : IdentifierKind, text~ : String, rule~ : IdentifierRule)
    } derive(Eq,
    Debug
    )

    A text that is not a valid identifier. Callers can match the cases, but only the smart constructors make them. The text of a connection token is never kept in the error.

    IdentifierError::equal

    automatically derived

    IdentifierError::message

    fn IdentifierError::message(self : IdentifierError) -> String

    Text for people that describes the fault.

    IdentifierError::not_equal

    fn IdentifierError::not_equal(x : IdentifierError, y : IdentifierError) -> Bool
    automatically derived

    IdentifierError::to_repr

    automatically derived

    LimitError

    pub suberror LimitError {
    NotPositiveTime(milliseconds~ : Int64)
    NotPositiveCount(count~ : Int)
    NotPositiveSize(bytes~ : Int)
    } derive(Eq,
    Debug
    )

    A value that is not a valid limit.

    LimitError::equal

    fn LimitError::equal(LimitError, LimitError) -> Bool
    automatically derived

    LimitError::message

    fn LimitError::message(self : LimitError) -> String

    Text for people that describes the fault.

    LimitError::not_equal

    fn LimitError::not_equal(x : LimitError, y : LimitError) -> Bool
    automatically derived

    LimitError::to_repr

    automatically derived

    ProtocolError

    pub suberror ProtocolError {
    InvalidJson(detail~ : String)
    NotAnObject
    MissingField(field~ : String)
    WrongFieldType(field~ : String, expected~ : String)
    UnknownField(field~ : String)
    UnsupportedMessageType(message_type~ : Int)
    BadIdentifier(field~ : String, error~ : IdentifierError)
    NumberOutOfRange(text~ : String)
    ResultAndError(invocation_id~ : InvocationId)
    InvocationIdInUse(invocation_id~ : InvocationId)
    StreamIdInUse(stream_id~ : StreamId)
    UnknownInvocation(invocation_id~ : InvocationId)
    StreamItemForInvocation(invocation_id~ : InvocationId)
    ResultAfterStreamItems(invocation_id~ : InvocationId)
    MessageBeforeHandshake
    UnexpectedMessage(message_type~ : Int)
    MessageTooLarge(limit~ : Int, size~ : Int)
    } derive(
    Debug
    )

    A fault in the hub protocol: a message that is not valid, or a message that breaks the invocation rules. An endpoint that gets one closes the connection with a Close message that names it.
    impl Eq for ProtocolError

    ProtocolError::equal

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

    ProtocolError::message

    fn ProtocolError::message(self : ProtocolError) -> String

    Text for people that describes the fault. A Close message holds this text.

    ProtocolError::not_equal

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

    ProtocolError::to_repr

    automatically derived

    TimestampError

    pub suberror TimestampError {
    InvalidTimestamp(input~ : String, rule~ : TimestampRule)
    } derive(Eq,
    Debug
    )

    A text or a value that is not a valid timestamp.

    TimestampError::equal

    automatically derived

    TimestampError::message

    fn TimestampError::message(self : TimestampError) -> String

    Text for people that describes the fault.

    TimestampError::not_equal

    fn TimestampError::not_equal(x : TimestampError, y : TimestampError) -> Bool
    automatically derived

    TimestampError::to_repr

    automatically derived

    UsageError

    pub suberror UsageError {
    NotOpen
    UnknownCall(invocation_id~ : InvocationId)
    NotAStream(invocation_id~ : InvocationId)
    ResultForStream(invocation_id~ : InvocationId)
    UnknownInvocation(invocation_id~ : InvocationId)
    UnknownStream(stream_id~ : StreamId)
    StreamFromServer
    } derive(Eq,
    Debug
    )

    A local operation that does not fit the state of the connection: a program fault, not a fault of the peer.

    UsageError::equal

    fn UsageError::equal(UsageError, UsageError) -> Bool
    automatically derived

    UsageError::not_equal

    fn UsageError::not_equal(x : UsageError, y : UsageError) -> Bool
    automatically derived

    UsageError::to_repr

    automatically derived

    AccessToken

    pub struct AccessToken {
    // private fields
    }

    A bearer access token, for example a JWT. It has 1 to 16384 characters, and no control or space characters. Show, Debug and parse errors write [REDACTED]. Only the request that sends the token reads it with expose.
    impl Eq for AccessToken
    impl Show for AccessToken

    AccessToken::equal

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

    AccessToken::expose

    fn AccessToken::expose(self : AccessToken) -> String

    The token text. Use it only to build the request that sends it.

    AccessToken::not_equal

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

    AccessToken::output

    fn AccessToken::output(_self : AccessToken, logger : &Logger) -> Unit

    AccessToken::parse

    fn AccessToken::parse(text : String) -> AccessToken raise IdentifierError

    Parse an access token. A parse error holds [REDACTED], not the text.

    AccessToken::to_repr

    AccessToken::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    Arguments

    pub struct Arguments[A] {
    // private fields
    }

    The positional arguments of a method, in the order of its parameters. A call with another number of arguments raises LengthMismatch at the path arguments with the number of parameters and the number of arguments.

    Arguments::count

    fn[A] Arguments::count(self : Arguments[A]) -> Int

    The number of parameters.

    Arguments::decode

    fn[A] Arguments::decode(self : Arguments[A], values : ReadOnlyArray[HubValue]) -> A raise CodecError

    Decode the arguments. Errors have paths that start with arguments.

    Arguments::encode

    fn[A] Arguments::encode(self : Arguments[A], value : A) -> Array[HubValue] raise CodecError

    Encode the arguments.

    AvailableTransport

    pub(all) struct AvailableTransport {
    transport : TransportKind
    formats : ReadOnlyArray[TransferFormat]
    } derive(Eq,
    Debug
    )

    A transport that a server offers, with its transfer formats.

    AvailableTransport::equal

    automatically derived

    AvailableTransport::not_equal

    automatically derived

    AvailableTransport::to_repr

    automatically derived

    AvailableTransport::websockets

    The WebSockets transport with the formats Text and Binary, which a Moon-Lander server offers.

    Call

    pub(all) struct Call {
    invocation_id : InvocationId?
    kind : CallKind
    target : MethodName
    arguments : ReadOnlyArray[HubValue]
    stream_ids : ReadOnlyArray[StreamId]
    headers : Headers
    } derive(Eq,
    Debug
    )

    A call that the peer made: the hub or the client handler runs it.

    Call::equal

    fn Call::equal(Call, Call) -> Bool
    automatically derived

    Call::not_equal

    fn Call::not_equal(x : Call, y : Call) -> Bool
    automatically derived

    Call::to_repr

    automatically derived

    CallKind

    pub(all) enum CallKind {
    Single
    Stream
    } derive(Eq,
    Debug
    )

    The kind of a call that has an ID: an Invocation with one result, or a StreamInvocation with stream items.

    CallKind::equal

    fn CallKind::equal(CallKind, CallKind) -> Bool
    automatically derived

    CallKind::not_equal

    fn CallKind::not_equal(x : CallKind, y : CallKind) -> Bool
    automatically derived

    CallKind::to_repr

    automatically derived

    CallMode

    pub(all) enum CallMode {
    Blocking
    NonBlocking
    Streaming
    } derive(Eq,
    Debug
    )

    How a local call waits for the peer.

    CallMode::equal

    fn CallMode::equal(CallMode, CallMode) -> Bool
    automatically derived

    CallMode::not_equal

    fn CallMode::not_equal(x : CallMode, y : CallMode) -> Bool
    automatically derived

    CallMode::to_repr

    automatically derived

    CancelInvocation

    pub(all) struct CancelInvocation {
    invocation_id : InvocationId
    headers : Headers
    } derive(Eq,
    Debug
    )

    A CancelInvocation (type 5).

    CancelInvocation::equal

    automatically derived

    CancelInvocation::not_equal

    fn CancelInvocation::not_equal(x : CancelInvocation, y : CancelInvocation) -> Bool
    automatically derived

    CancelInvocation::to_repr

    automatically derived

    ClientCall

    pub struct ClientCall[A, R] {
    // private fields
    }

    A client method with a result: the hub calls it on one client and waits for the result.

    ClientCall::arguments

    fn[A, R] ClientCall::arguments(self : ClientCall[A, R]) -> Arguments[A]

    The codecs of the arguments.

    ClientCall::name

    fn[A, R] ClientCall::name(self : ClientCall[A, R]) -> MethodName

    The method name.

    ClientCall::new

    fn[A, R] ClientCall::new(name : MethodName, arguments : Arguments[A], result : Codec[R]) -> ClientCall[A, R]

    A client method with a result.

    ClientCall::result

    fn[A, R] ClientCall::result(self : ClientCall[A, R]) -> Codec[R]

    The codec of the result.

    ClientMethod

    pub struct ClientMethod[A] {
    // private fields
    }

    A client method: the method that the hub calls on a client.

    ClientMethod::arguments

    fn[A] ClientMethod::arguments(self : ClientMethod[A]) -> Arguments[A]

    The codecs of the arguments.

    ClientMethod::name

    fn[A] ClientMethod::name(self : ClientMethod[A]) -> MethodName

    The method name.

    ClientMethod::new

    fn[A] ClientMethod::new(name : MethodName, arguments : Arguments[A]) -> ClientMethod[A]

    A client method with no result.

    Clock

    pub struct Clock {
    // private fields
    }

    The time of a server or a client (design SRV-3). Each time limit uses now and sleep of one clock, so a test gives a clock that it moves itself. The server and the client packages give the clock of the platform.

    Clock::new

    fn Clock::new(now~ : () -> Int64, sleep~ : async (Int) -> Unit) -> Clock

    A clock from now, which gives the time in milliseconds from any fixed point, and sleep, which waits for a number of milliseconds.

    Clock::now

    fn Clock::now(self : Clock) -> Int64

    The time in milliseconds.

    Clock::sleep_until

    async fn Clock::sleep_until(self : Clock, at : Int64) -> Unit

    Wait until the clock reaches at.

    Close

    pub(all) struct Close {
    error : String?
    allow_reconnect : Bool
    headers : Headers
    } derive(Eq,
    Debug
    )

    A Close message (type 7). error is set only when the connection ends because of an error.

    Close::equal

    fn Close::equal(Close, Close) -> Bool
    automatically derived

    Close::not_equal

    fn Close::not_equal(x : Close, y : Close) -> Bool
    automatically derived

    Close::to_repr

    automatically derived

    Codec

    pub struct Codec[T] {
    // private fields
    }

    The conversion of a MoonBit type T to and from a payload value (design CDC-2). A decode builds a domain value only through its smart constructor; see Codec::parse.

    Codec::decode

    fn[T] Codec::decode(self : Codec[T], value : HubValue, path? : Path) -> T raise CodecError

    Decode value. path names the value in errors; the default is $.

    Codec::encode

    fn[T] Codec::encode(self : Codec[T], value : T, path? : Path) -> HubValue raise CodecError

    Encode value. path names the value in errors; the default is $.

    Codec::has_no_result

    fn[T] Codec::has_no_result(self : Codec[T]) -> Bool

    True for unit(): a method with this result codec has no result, so its Completion holds none.

    Codec::map

    fn[A, B] Codec::map(self : Codec[A], from : (A) -> B, to : (B) -> A) -> Codec[B]

    A codec for B through two total functions.

    Codec::new

    fn[T] Codec::new(encode~ : (T, Path) -> HubValue raise CodecError, decode~ : (HubValue, Path) -> T raise CodecError) -> Codec[T]

    A codec from an encode function and a decode function. Each function gets the path of the value for its errors.

    Codec::parse

    fn[A, B] Codec::parse(self : Codec[A], parse : (A) -> B raise?, to_raw : (B) -> A) -> Codec[B]

    A codec for B that decodes an A and then runs parse, the smart constructor of B. An error of parse becomes Rejected with the path and that error. to_raw gives the A of a B to encode.

    Completion

    pub(all) struct Completion {
    invocation_id : InvocationId
    outcome : Outcome
    headers : Headers
    } derive(Eq,
    Debug
    )

    A Completion (type 3): the end of an invocation, a server stream or an upload stream.

    Completion::equal

    fn Completion::equal(Completion, Completion) -> Bool
    automatically derived

    Completion::not_equal

    fn Completion::not_equal(x : Completion, y : Completion) -> Bool
    automatically derived

    Completion::to_repr

    automatically derived

    ConnectionId

    pub struct ConnectionId {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The public ID of a connection. It has 1 to 256 characters, and no control or space characters.

    ConnectionId::equal

    automatically derived

    ConnectionId::hash

    fn ConnectionId::hash(self : ConnectionId) -> Int
    automatically derived

    ConnectionId::hash_combine

    fn ConnectionId::hash_combine(ConnectionId, Hasher) -> Unit
    automatically derived

    ConnectionId::not_equal

    fn ConnectionId::not_equal(x : ConnectionId, y : ConnectionId) -> Bool
    automatically derived

    ConnectionId::output

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

    ConnectionId::parse

    fn ConnectionId::parse(text : String) -> ConnectionId raise IdentifierError

    Parse a connection ID.

    ConnectionId::to_repr

    automatically derived

    ConnectionId::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    ConnectionToken

    pub struct ConnectionToken {
    // private fields
    }

    The private token of a connection. It has the rules of a connection ID. Show, Debug and parse errors write [REDACTED] in place of the token. Only the transport request that needs the token reads it with expose.

    ConnectionToken::equal

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

    Two tokens are equal when their texts are equal.

    ConnectionToken::expose

    fn ConnectionToken::expose(self : ConnectionToken) -> String

    The token text. Use it only to build the transport request.

    ConnectionToken::hash

    fn ConnectionToken::hash(self : ConnectionToken) -> Int

    ConnectionToken::hash_combine

    fn ConnectionToken::hash_combine(self : ConnectionToken, hasher : Hasher) -> Unit

    ConnectionToken::not_equal

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

    ConnectionToken::output

    fn ConnectionToken::output(_self : ConnectionToken, logger : &Logger) -> Unit

    ConnectionToken::parse

    fn ConnectionToken::parse(text : String) -> ConnectionToken raise IdentifierError

    Parse a connection token. A parse error holds [REDACTED], not the text.

    ConnectionToken::to_repr

    ConnectionToken::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    CountLimit

    pub struct CountLimit {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A limit of a number of items, 1 or more: queued messages or parallel calls.

    CountLimit::compare

    fn CountLimit::compare(CountLimit, CountLimit) -> Int
    automatically derived

    CountLimit::default_outgoing_messages

    fn CountLimit::default_outgoing_messages() -> CountLimit

    The default number of outgoing messages that wait for one connection: 128.

    CountLimit::default_parallel_calls

    fn CountLimit::default_parallel_calls() -> CountLimit

    The default number of calls of one connection that run at the same time, as in ASP.NET Core SignalR: 1, so that the calls run in the order of arrival.

    CountLimit::equal

    fn CountLimit::equal(CountLimit, CountLimit) -> Bool
    automatically derived

    CountLimit::hash

    fn CountLimit::hash(self : CountLimit) -> Int
    automatically derived

    CountLimit::hash_combine

    fn CountLimit::hash_combine(CountLimit, Hasher) -> Unit
    automatically derived

    CountLimit::not_equal

    fn CountLimit::not_equal(x : CountLimit, y : CountLimit) -> Bool
    automatically derived

    CountLimit::of

    fn CountLimit::of(count : Int) -> CountLimit raise LimitError

    A limit of count items.

    CountLimit::to_int

    fn CountLimit::to_int(self : CountLimit) -> Int

    The limit as a number.

    CountLimit::to_repr

    automatically derived

    Credentials

    pub(all) struct Credentials {
    token : AccessToken?
    } derive(Eq,
    Debug
    )

    What a request gives to prove who sends it: the access token of the Authorization: Bearer header or of the access_token query value. The debug representation shows [REDACTED] for the token.

    Credentials::equal

    fn Credentials::equal(Credentials, Credentials) -> Bool
    automatically derived

    Credentials::not_equal

    fn Credentials::not_equal(x : Credentials, y : Credentials) -> Bool
    automatically derived

    Credentials::to_repr

    automatically derived

    DisconnectCause

    pub(all) enum DisconnectCause {
    ClientClosed(String?)
    TimedOut
    HandshakeTimedOut
    TransportError(String)
    ProtocolViolation(String)
    ClosedByServer
    SlowClient
    ServerStopped
    } derive(Eq,
    Debug
    )

    Why a connection ended.

    DisconnectCause::equal

    automatically derived

    DisconnectCause::not_equal

    fn DisconnectCause::not_equal(x : DisconnectCause, y : DisconnectCause) -> Bool
    automatically derived

    DisconnectCause::to_repr

    automatically derived

    EndpointPath

    pub struct EndpointPath {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The URL path of a hub endpoint, for example /chat or /hubs/chat. It starts with /, has one or more nonempty segments, and holds only ASCII letters, digits, -, ., _ and ~ in a segment. It has at most 256 characters.

    EndpointPath::equal

    automatically derived

    EndpointPath::hash

    fn EndpointPath::hash(self : EndpointPath) -> Int
    automatically derived

    EndpointPath::hash_combine

    fn EndpointPath::hash_combine(EndpointPath, Hasher) -> Unit
    automatically derived

    EndpointPath::negotiate

    fn EndpointPath::negotiate(self : EndpointPath) -> String

    The negotiate path: the endpoint path followed by /negotiate.

    EndpointPath::not_equal

    fn EndpointPath::not_equal(x : EndpointPath, y : EndpointPath) -> Bool
    automatically derived

    EndpointPath::output

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

    EndpointPath::parse

    fn EndpointPath::parse(text : String) -> EndpointPath raise IdentifierError

    Parse an endpoint path.

    EndpointPath::to_repr

    automatically derived

    EndpointPath::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    EnumMapping

    pub struct EnumMapping[T, W] {
    // private fields
    }

    The wire value of each case of an enum. Each wire value belongs to one case, so each case comes back from a round trip.

    EnumMapping::new

    fn[T : Eq, W : Eq + Show] EnumMapping::new(cases : ArrayView[(T, W)]) -> EnumMapping[T, W] raise EnumMappingError

    The mapping of cases. A case can have more than one wire value: encode uses the first one, and decode reads each. A wire value of two different cases raises AmbiguousValue.

    Event

    pub(all) struct Event {
    role : Role
    output : Output
    } derive(Eq,
    Debug
    )

    An output of one side of a MemoryPair, other than text to send.

    Event::equal

    fn Event::equal(Event, Event) -> Bool
    automatically derived

    Event::not_equal

    fn Event::not_equal(x : Event, y : Event) -> Bool
    automatically derived

    Event::to_repr

    automatically derived

    Field

    pub struct Field[R, F] {
    // private fields
    }

    A property of a record codec: the property name, the codec of the value and the function that reads the value from the record.

    Field::property

    fn[R, F] Field::property(self : Field[R, F]) -> String

    The property name.

    FiniteDouble

    pub struct FiniteDouble {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A finite double: not NaN and not infinite.

    FiniteDouble::compare

    automatically derived

    FiniteDouble::equal

    automatically derived

    FiniteDouble::hash

    fn FiniteDouble::hash(self : FiniteDouble) -> Int
    automatically derived

    FiniteDouble::hash_combine

    fn FiniteDouble::hash_combine(FiniteDouble, Hasher) -> Unit
    automatically derived

    FiniteDouble::not_equal

    fn FiniteDouble::not_equal(x : FiniteDouble, y : FiniteDouble) -> Bool
    automatically derived

    FiniteDouble::parse

    fn FiniteDouble::parse(value : Double) -> FiniteDouble raise HubValueError

    Parse a finite double.

    FiniteDouble::to_repr

    automatically derived

    FiniteDouble::value

    fn FiniteDouble::value(self : FiniteDouble) -> Double

    The double.

    FrameBuffer

    pub struct FrameBuffer {
    // private fields
    }

    The text of the messages that arrived on a connection and do not end yet. The value is immutable: push gives a new buffer. It keeps the parts of an incomplete message, so many small frames cost no more than one large frame.
    impl Eq for FrameBuffer

    FrameBuffer::empty

    fn FrameBuffer::empty() -> FrameBuffer

    The buffer with no text.

    FrameBuffer::equal

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

    Two buffers are equal when the same text waits.

    FrameBuffer::not_equal

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

    FrameBuffer::pending_length

    fn FrameBuffer::pending_length(self : FrameBuffer) -> Int

    The length, in UTF-16 code units, of the text that waits for its record separator.

    FrameBuffer::pending_utf8_length

    fn FrameBuffer::pending_utf8_length(self : FrameBuffer) -> Int

    The length, in UTF-8 bytes, of the text that waits for its record separator.

    FrameBuffer::push

    fn FrameBuffer::push(self : FrameBuffer, text : StringView) -> (FrameBuffer, Array[String])

    Add the text of one frame, or a part of it that ends between two characters. The result gives the new buffer and the complete messages, in order, without their record separators. An incomplete trailing message stays in the buffer until more text arrives.

    FrameBuffer::to_repr

    GroupName

    pub struct GroupName {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The name of a group of connections. It has 1 to 256 characters and no control characters.
    impl Show for GroupName

    GroupName::equal

    fn GroupName::equal(GroupName, GroupName) -> Bool
    automatically derived

    GroupName::hash

    fn GroupName::hash(self : GroupName) -> Int
    automatically derived

    GroupName::hash_combine

    fn GroupName::hash_combine(GroupName, Hasher) -> Unit
    automatically derived

    GroupName::not_equal

    fn GroupName::not_equal(x : GroupName, y : GroupName) -> Bool
    automatically derived

    GroupName::output

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

    GroupName::parse

    fn GroupName::parse(text : String) -> GroupName raise IdentifierError

    Parse a group name.

    GroupName::to_repr

    automatically derived

    GroupName::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    HandshakeRequest

    pub(all) struct HandshakeRequest {
    protocol : String
    version : Int
    } derive(Eq,
    Debug
    )

    The handshake request that a client sends first: the protocol name and its version. Handshake messages are JSON for every protocol.

    HandshakeRequest::equal

    automatically derived

    HandshakeRequest::json

    The request for the JSON protocol, version 1.

    HandshakeRequest::not_equal

    fn HandshakeRequest::not_equal(x : HandshakeRequest, y : HandshakeRequest) -> Bool
    automatically derived

    HandshakeRequest::parse

    fn HandshakeRequest::parse(text : StringView) -> HandshakeRequest raise ProtocolError

    Read a handshake request from its JSON text, without the record separator. Properties that the reader does not know are ignored.

    HandshakeRequest::to_frame

    fn HandshakeRequest::to_frame(self : HandshakeRequest) -> String

    The framed text of the request.

    HandshakeRequest::to_repr

    automatically derived

    HandshakeResponse

    pub(all) enum HandshakeResponse {
    Accepted
    Refused(String)
    } derive(Eq,
    Debug
    )

    The handshake response of a server: accepted ({}) or refused with an error text.

    HandshakeResponse::equal

    automatically derived

    HandshakeResponse::for_request

    The response of a server that supports only the JSON protocol, version 1, to request. The error texts are the texts of ASP.NET Core.

    HandshakeResponse::not_equal

    fn HandshakeResponse::not_equal(x : HandshakeResponse, y : HandshakeResponse) -> Bool
    automatically derived

    HandshakeResponse::parse

    fn HandshakeResponse::parse(text : StringView) -> HandshakeResponse raise ProtocolError

    Read a handshake response from its JSON text, without the record separator. Properties that the reader does not know are ignored.

    HandshakeResponse::to_frame

    fn HandshakeResponse::to_frame(self : HandshakeResponse) -> String

    The framed text of the response.

    HandshakeResponse::to_repr

    automatically derived

    Headers

    pub struct Headers {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The headers of a hub message: string keys, each one time, with string values.

    Headers::empty

    fn Headers::empty() -> Headers

    No headers.

    Headers::equal

    fn Headers::equal(Headers, Headers) -> Bool
    automatically derived

    Headers::get

    fn Headers::get(self : Headers, key : String) -> String?

    The value of the header key.

    Headers::hash

    fn Headers::hash(self : Headers) -> Int
    automatically derived

    Headers::hash_combine

    fn Headers::hash_combine(Headers, Hasher) -> Unit
    automatically derived

    Headers::is_empty

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

    True when there are no headers.

    Headers::iter

    fn Headers::iter(self : Headers) -> Iter[(String, String)]

    The headers in their order.

    Headers::new

    fn Headers::new(entries : ArrayView[(String, String)]) -> Headers raise HubValueError

    The headers of entries. A key that comes two times raises DuplicateKey.

    Headers::not_equal

    fn Headers::not_equal(x : Headers, y : Headers) -> Bool
    automatically derived

    Headers::to_repr

    automatically derived

    HubContract

    pub struct HubContract {
    // private fields
    }

    A hub contract: the hub name, the hub methods and the client methods (design CON-1). Method names are unique in each direction and case-sensitive. The value is immutable: each builder call gives a new contract.

    HubContract::check_call

    fn HubContract::check_call(self : HubContract, call : Call) -> Result[MethodInfo, String]

    The hub method of a call, or the error text for the Completion when the call does not fit the contract: an unknown method, or a call of the wrong kind. The texts for the wrong kind are the texts of ASP.NET Core.

    HubContract::client

    fn[A] HubContract::client(self : HubContract, method_ : ClientMethod[A]) -> HubContract raise ContractError

    Add a client method. A name that the contract has for a client method raises DuplicateClientMethod.

    HubContract::client_call

    fn[A, R] HubContract::client_call(self : HubContract, call : ClientCall[A, R]) -> HubContract raise ContractError

    Add a client method with a result. Its name is in the same set as the names of the client methods with no result.

    HubContract::client_methods

    fn HubContract::client_methods(self : HubContract) -> Array[MethodInfo]

    The client methods, in the order in which they were added.

    HubContract::hub_methods

    fn HubContract::hub_methods(self : HubContract) -> Array[MethodInfo]

    The hub methods, in the order in which they were added.

    HubContract::name

    fn HubContract::name(self : HubContract) -> HubName

    The hub name.

    HubContract::new

    fn HubContract::new(name : HubName) -> HubContract

    A contract with no methods.

    HubContract::server

    fn[A, R] HubContract::server(self : HubContract, method_ : HubMethod[A, R]) -> HubContract raise ContractError

    Add a hub method. A name that the contract has for a hub method raises DuplicateHubMethod.

    HubMap

    pub struct HubMap {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    A map of a payload value: string keys in the order in which they were added, each key one time. The value is immutable; add gives a new map.

    HubMap::add

    fn HubMap::add(self : HubMap, key : String, value : HubValue) -> HubMap raise HubValueError

    A new map with the entries of self and then key with value. A key that self has raises DuplicateKey.

    HubMap::empty

    fn HubMap::empty() -> HubMap

    The map with no keys.

    HubMap::equal

    fn HubMap::equal(HubMap, HubMap) -> Bool
    automatically derived

    HubMap::get

    fn HubMap::get(self : HubMap, key : String) -> HubValue?

    The value of key.

    HubMap::get_ignore_case

    fn HubMap::get_ignore_case(self : HubMap, key : String) -> HubValue?

    The value of key. When no key is equal to key, the first key that is equal to it with no regard to case. This is the property match of System.Text.Json with PropertyNameCaseInsensitive.

    HubMap::hash

    fn HubMap::hash(self : HubMap) -> Int
    automatically derived

    HubMap::hash_combine

    fn HubMap::hash_combine(HubMap, Hasher) -> Unit
    automatically derived

    HubMap::iter

    fn HubMap::iter(self : HubMap) -> Iter[(String, HubValue)]

    The entries in the order in which they were added.

    HubMap::keys

    fn HubMap::keys(self : HubMap) -> Array[String]

    The keys in the order in which they were added.

    HubMap::length

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

    The number of keys.

    HubMap::new

    fn HubMap::new(entries : ArrayView[(String, HubValue)]) -> HubMap raise HubValueError

    The map of entries, in their order. A key that comes two times raises DuplicateKey with that key.

    HubMap::not_equal

    fn HubMap::not_equal(x : HubMap, y : HubMap) -> Bool
    automatically derived

    HubMap::to_repr

    automatically derived

    HubMessage

    pub(all) enum HubMessage {
    Invocation(Invocation)
    StreamItem(StreamItem)
    Completion(Completion)
    StreamInvocation(StreamInvocation)
    CancelInvocation(CancelInvocation)
    Ping
    Close(Close)
    } derive(Eq,
    Debug
    )

    A message of the SignalR hub protocol.

    HubMessage::equal

    fn HubMessage::equal(HubMessage, HubMessage) -> Bool
    automatically derived

    HubMessage::message_type

    fn HubMessage::message_type(self : HubMessage) -> Int

    The message type number of the protocol, from 1 to 7.

    HubMessage::not_equal

    fn HubMessage::not_equal(x : HubMessage, y : HubMessage) -> Bool
    automatically derived

    HubMessage::parse

    fn HubMessage::parse(text : StringView) -> HubMessage raise ProtocolError

    Read one hub message from its JSON text, without the record separator. The reader is strict: a missing required field, a field of the wrong type and a field that the type does not define are errors.

    HubMessage::to_frame

    fn HubMessage::to_frame(self : HubMessage) -> String

    The framed text of the message: its JSON text and the record separator.

    HubMessage::to_json_text

    fn HubMessage::to_json_text(self : HubMessage) -> String

    The JSON text of the message, with no record separator. type is the first property, as the .NET writer gives it.

    HubMessage::to_repr

    automatically derived

    HubMethod

    pub struct HubMethod[A, R] {
    // private fields
    }

    A hub method: the method that a client calls on the hub. It has a name, the codecs of its arguments and the codec of its result, or of its stream items for a streaming method.

    HubMethod::arguments

    fn[A, R] HubMethod::arguments(self : HubMethod[A, R]) -> Arguments[A]

    The codecs of the arguments.

    HubMethod::call

    fn[A, R] HubMethod::call(name : MethodName, arguments : Arguments[A], result : Codec[R]) -> HubMethod[A, R]

    A hub method with one result. Use unit() for a method with no result.

    HubMethod::kind

    fn[A, R] HubMethod::kind(self : HubMethod[A, R]) -> CallKind

    Single for a method with one result, Stream for a streaming method.

    HubMethod::name

    fn[A, R] HubMethod::name(self : HubMethod[A, R]) -> MethodName

    The method name.

    HubMethod::result

    fn[A, R] HubMethod::result(self : HubMethod[A, R]) -> Codec[R]

    The codec of the result, or of the stream items.

    HubMethod::stream

    fn[A, R] HubMethod::stream(name : MethodName, arguments : Arguments[A], item : Codec[R]) -> HubMethod[A, R]

    A streaming hub method: a client starts it with a StreamInvocation, and it sends items of the type R.

    HubName

    pub struct HubName {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The name of a hub, for example chat. It starts with an ASCII letter and holds only ASCII letters, digits, - and _, with at most 128 characters.
    impl Show for HubName

    HubName::equal

    fn HubName::equal(HubName, HubName) -> Bool
    automatically derived

    HubName::hash

    fn HubName::hash(self : HubName) -> Int
    automatically derived

    HubName::hash_combine

    fn HubName::hash_combine(HubName, Hasher) -> Unit
    automatically derived

    HubName::not_equal

    fn HubName::not_equal(x : HubName, y : HubName) -> Bool
    automatically derived

    HubName::output

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

    HubName::parse

    fn HubName::parse(text : String) -> HubName raise IdentifierError

    Parse a hub name.

    HubName::to_repr

    automatically derived

    HubName::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    HubValue

    pub(all) enum HubValue {
    Null
    Bool(Bool)
    Int(Int64)
    UInt(UInt64)
    Double(FiniteDouble)
    String(String)
    Bytes(Bytes)
    Timestamp(Timestamp)
    Array(ReadOnlyArray[HubValue])
    Map(HubMap)
    } derive(Eq, Hash,
    Debug
    )

    A payload value that each hub protocol encoding can write completely (design CDC-1). Arguments, stream items and results pass through this tree.

    HubValue::array

    fn HubValue::array(items : ArrayView[HubValue]) -> HubValue

    The array value of items.

    HubValue::equal

    fn HubValue::equal(HubValue, HubValue) -> Bool
    automatically derived

    HubValue::from_json

    The payload value of a JSON value. A number that is exactly an integer, also with an exponent, gives Int, or UInt above the range of Int64. Another number gives Double, so a Double from JSON is never an exact 64-bit integer. A JSON string stays a string: a codec reads Base64 bytes and timestamps from it.

    HubValue::hash

    fn HubValue::hash(self : HubValue) -> Int
    automatically derived

    HubValue::hash_combine

    fn HubValue::hash_combine(HubValue, Hasher) -> Unit
    automatically derived

    HubValue::kind

    fn HubValue::kind(self : HubValue) -> ValueKind

    The kind of self. Int and UInt are both Integer.

    HubValue::not_equal

    fn HubValue::not_equal(x : HubValue, y : HubValue) -> Bool
    automatically derived

    HubValue::parse_json

    fn HubValue::parse_json(text : StringView) -> HubValue raise ProtocolError

    Read a payload value from JSON text.

    HubValue::to_json

    The JSON value of a payload value: integers with their exact digits, bytes as Base64 text with padding, and timestamps as ISO 8601 text in UTC.

    HubValue::to_json_text

    fn HubValue::to_json_text(self : HubValue) -> String

    The compact JSON text of a payload value.

    HubValue::to_repr

    automatically derived

    IdentifierKind

    pub(all) enum IdentifierKind {
    HubName
    MethodName
    InvocationId
    StreamId
    ConnectionId
    ConnectionToken
    UserId
    GroupName
    EndpointPath
    AccessToken
    } derive(Eq,
    Debug
    )

    The kind of a SignalR identifier or name. A parse error names it, so a caller knows which value failed.

    IdentifierKind::equal

    automatically derived

    IdentifierKind::not_equal

    fn IdentifierKind::not_equal(x : IdentifierKind, y : IdentifierKind) -> Bool
    automatically derived

    IdentifierKind::to_repr

    automatically derived

    IdentifierRule

    pub(all) enum IdentifierRule {
    Empty
    TooLong(limit~ : Int, length~ : Int)
    FirstCharNotAllowed(Char)
    CharNotAllowed(Char)
    NoLeadingSlash
    EmptySegment
    } derive(Eq,
    Debug
    )

    The rule of an identifier that a text breaks.

    IdentifierRule::equal

    automatically derived

    IdentifierRule::not_equal

    fn IdentifierRule::not_equal(x : IdentifierRule, y : IdentifierRule) -> Bool
    automatically derived

    IdentifierRule::to_repr

    automatically derived

    Identity

    pub struct Identity {
    // private fields
    } derive(Eq,
    Debug
    )

    Who a connection belongs to: an optional user ID, and the claims that the authenticator gives. An identity with no user ID is anonymous.

    Identity::anonymous

    fn Identity::anonymous() -> Identity

    The identity with no user ID and no claims.

    Identity::claims

    fn Identity::claims(self : Identity) -> Iter[(String, String)]

    The claims in their order.

    Identity::equal

    fn Identity::equal(Identity, Identity) -> Bool
    automatically derived

    Identity::has_claim

    fn Identity::has_claim(self : Identity, name : String, value : String) -> Bool

    True when the identity has the claim name with value.

    Identity::not_equal

    fn Identity::not_equal(x : Identity, y : Identity) -> Bool
    automatically derived

    Identity::to_repr

    automatically derived

    Identity::user

    fn Identity::user(user_id : UserId, claims? : ArrayView[(String, String)]) -> Identity

    The identity of the user user_id with claims. A claim name can come more than one time, for example role.

    Identity::user_id

    fn Identity::user_id(self : Identity) -> UserId?

    The user ID, or None for an anonymous identity.

    Invocation

    pub(all) struct Invocation {
    invocation_id : InvocationId?
    target : MethodName
    arguments : ReadOnlyArray[HubValue]
    stream_ids : ReadOnlyArray[StreamId]
    headers : Headers
    } derive(Eq,
    Debug
    )

    An Invocation (type 1). With no ID it is a non-blocking invocation: the callee sends no reply.

    Invocation::equal

    fn Invocation::equal(Invocation, Invocation) -> Bool
    automatically derived

    Invocation::not_equal

    fn Invocation::not_equal(x : Invocation, y : Invocation) -> Bool
    automatically derived

    Invocation::to_repr

    automatically derived

    InvocationId

    pub struct InvocationId {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The ID of an invocation that the caller chooses for each connection. It has 1 to 128 characters and no control characters (signalr-protocol, "Invocation identifiers").

    InvocationId::equal

    automatically derived

    InvocationId::from_counter

    fn InvocationId::from_counter(value : UInt64) -> InvocationId

    The invocation ID for a counter value, as the .NET and JavaScript clients write it: the decimal text of value.

    InvocationId::hash

    fn InvocationId::hash(self : InvocationId) -> Int
    automatically derived

    InvocationId::hash_combine

    fn InvocationId::hash_combine(InvocationId, Hasher) -> Unit
    automatically derived

    InvocationId::not_equal

    fn InvocationId::not_equal(x : InvocationId, y : InvocationId) -> Bool
    automatically derived

    InvocationId::output

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

    InvocationId::parse

    fn InvocationId::parse(text : String) -> InvocationId raise IdentifierError

    Parse an invocation ID.

    InvocationId::to_repr

    automatically derived

    InvocationId::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    Invoked

    pub(all) struct Invoked {
    invocation_id : InvocationId?
    stream_ids : ReadOnlyArray[StreamId]
    } derive(Eq,
    Debug
    )

    The IDs of a local call.

    Invoked::equal

    fn Invoked::equal(Invoked, Invoked) -> Bool
    automatically derived

    Invoked::not_equal

    fn Invoked::not_equal(x : Invoked, y : Invoked) -> Bool
    automatically derived

    Invoked::to_repr

    automatically derived

    KeepAlive

    pub struct KeepAlive {
    // private fields
    } derive(Eq,
    Debug
    )

    The keep-alive state of one connection, on a clock that the caller gives as milliseconds (design SRV-3). The value is immutable, so tests use any times and need no real clock.

    KeepAlive::action

    fn KeepAlive::action(self : KeepAlive, now : Int64) -> TimerAction

    The action at now. A timeout comes before a Ping.

    KeepAlive::equal

    fn KeepAlive::equal(KeepAlive, KeepAlive) -> Bool
    automatically derived

    KeepAlive::handshake_completed

    fn KeepAlive::handshake_completed(self : KeepAlive, now : Int64) -> KeepAlive

    The handshake completed at now.

    KeepAlive::new

    fn KeepAlive::new(now : Int64, interval? : TimeLimit, timeout? : TimeLimit, handshake_timeout? : TimeLimit) -> KeepAlive

    The state of a connection that opened at now.

    KeepAlive::not_equal

    fn KeepAlive::not_equal(x : KeepAlive, y : KeepAlive) -> Bool
    automatically derived

    KeepAlive::received

    fn KeepAlive::received(self : KeepAlive, now : Int64) -> KeepAlive

    The peer sent a message at now.

    KeepAlive::sent

    fn KeepAlive::sent(self : KeepAlive, now : Int64) -> KeepAlive

    The endpoint sent a message at now.

    KeepAlive::to_repr

    automatically derived

    MemoryPair

    pub struct MemoryPair {
    // private fields
    }

    A client state machine and a server state machine that an in-memory transport connects. Each Send of one side goes to the other side, so the protocol runs with no socket and no event loop. The value is immutable.

    MemoryPair::client_call

    fn MemoryPair::client_call(self : MemoryPair, mode : CallMode, target : MethodName, arguments : ArrayView[HubValue], uploads? : Int) -> (MemoryPair, Invoked, Array[Event]) raise UsageError

    Start a call on the client, deliver the texts, and give the IDs of the call and the events of both sides.

    MemoryPair::client_state

    fn MemoryPair::client_state(self : MemoryPair) -> ProtocolState

    The client state.

    MemoryPair::connect

    fn MemoryPair::connect() -> (MemoryPair, Array[Event])

    Connect a new client to a new server and run the handshake.

    MemoryPair::on_client

    fn MemoryPair::on_client(self : MemoryPair, step : (ProtocolState) -> (ProtocolState, Array[Output]) raise) -> (MemoryPair, Array[Event]) raise

    Run step on the client state, deliver the texts, and give the events of both sides.

    MemoryPair::on_server

    fn MemoryPair::on_server(self : MemoryPair, step : (ProtocolState) -> (ProtocolState, Array[Output]) raise) -> (MemoryPair, Array[Event]) raise

    Run step on the server state, deliver the texts, and give the events of both sides.

    MemoryPair::server_state

    fn MemoryPair::server_state(self : MemoryPair) -> ProtocolState

    The server state.

    MethodInfo

    pub(all) struct MethodInfo {
    name : MethodName
    kind : CallKind
    parameters : Int
    } derive(Eq,
    Debug
    )

    The name and the kind of a hub method in a contract.

    MethodInfo::equal

    fn MethodInfo::equal(MethodInfo, MethodInfo) -> Bool
    automatically derived

    MethodInfo::not_equal

    fn MethodInfo::not_equal(x : MethodInfo, y : MethodInfo) -> Bool
    automatically derived

    MethodInfo::to_repr

    automatically derived

    MethodName

    pub struct MethodName {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The name of a hub method or a client method, for example sendMessage. It has 1 to 128 characters, and no control or space characters.
    impl Show for MethodName

    MethodName::equal

    fn MethodName::equal(MethodName, MethodName) -> Bool
    automatically derived

    MethodName::hash

    fn MethodName::hash(self : MethodName) -> Int
    automatically derived

    MethodName::hash_combine

    fn MethodName::hash_combine(MethodName, Hasher) -> Unit
    automatically derived

    MethodName::not_equal

    fn MethodName::not_equal(x : MethodName, y : MethodName) -> Bool
    automatically derived

    MethodName::output

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

    MethodName::parse

    fn MethodName::parse(text : String) -> MethodName raise IdentifierError

    Parse a method name.

    MethodName::to_repr

    automatically derived

    MethodName::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    NegotiateResponse

    pub(all) enum NegotiateResponse {
    Connection(NegotiatedConnection)
    Redirect(url~ : String, access_token~ : AccessToken?)
    Refused(String)
    } derive(Eq,
    Debug
    )

    A negotiate response: a connection, a redirect to another server, or a refusal with an error text.

    NegotiateResponse::equal

    automatically derived

    NegotiateResponse::not_equal

    fn NegotiateResponse::not_equal(x : NegotiateResponse, y : NegotiateResponse) -> Bool
    automatically derived

    NegotiateResponse::parse

    fn NegotiateResponse::parse(text : StringView) -> NegotiateResponse raise ProtocolError

    Read a negotiate response from its JSON text. Properties that the reader does not know are ignored, so that a newer server does not break it.

    NegotiateResponse::to_json_text

    fn NegotiateResponse::to_json_text(self : NegotiateResponse) -> String

    The JSON text of the response, as a server writes it.

    NegotiateResponse::to_repr

    automatically derived

    NegotiateVersion

    pub(all) enum NegotiateVersion {
    Version0
    Version1
    } derive(Eq,
    Debug
    )

    A version of the negotiate request that the protocol defines.

    NegotiateVersion::equal

    automatically derived

    NegotiateVersion::not_equal

    fn NegotiateVersion::not_equal(x : NegotiateVersion, y : NegotiateVersion) -> Bool
    automatically derived

    NegotiateVersion::to_repr

    automatically derived

    NegotiatedConnection

    pub(all) struct NegotiatedConnection {
    connection_id : ConnectionId
    token : NegotiatedToken
    transports : ReadOnlyArray[AvailableTransport]
    } derive(Eq,
    Debug
    )

    A negotiated connection. The debug representation shows the connection ID and [REDACTED] for the token.

    NegotiatedConnection::equal

    automatically derived

    NegotiatedConnection::negotiate_version

    The negotiate version of the connection.

    NegotiatedConnection::not_equal

    automatically derived

    NegotiatedConnection::to_repr

    automatically derived

    NegotiatedConnection::transport_id

    fn NegotiatedConnection::transport_id(self : NegotiatedConnection) -> String

    The text of the id query value of the transport request: the token for version 1 and later, the connection ID for version 0.

    NegotiatedToken

    pub(all) enum NegotiatedToken {
    Version0
    Version1(ConnectionToken)
    } derive(Eq,
    Debug
    )

    The connection token that a negotiate version gives. Version 0 has no token; a client then connects with the connection ID. The token of version 1 is separate from the connection ID.

    NegotiatedToken::equal

    automatically derived

    NegotiatedToken::not_equal

    fn NegotiatedToken::not_equal(x : NegotiatedToken, y : NegotiatedToken) -> Bool
    automatically derived

    NegotiatedToken::to_repr

    automatically derived

    Outcome

    pub(all) enum Outcome {
    NoResult
    Result(HubValue)
    Error(String)
    } derive(Eq,
    Debug
    )

    The outcome of a Completion: no result, a result or an error. A Completion with a result and an error cannot exist.

    Outcome::equal

    fn Outcome::equal(Outcome, Outcome) -> Bool
    automatically derived

    Outcome::not_equal

    fn Outcome::not_equal(x : Outcome, y : Outcome) -> Bool
    automatically derived

    Outcome::to_repr

    automatically derived

    Output

    pub(all) enum Output {
    Send(String)
    HandshakeCompleted
    HandshakeFailed(String)
    Dispatch(Call)
    ItemReceived(InvocationId, HubValue)
    Completed(InvocationId, Outcome)
    UploadItem(StreamId, HubValue)
    UploadEnded(StreamId, String?)
    CancelRequested(InvocationId)
    CloseReceived(Close)
    Violation(ProtocolError)
    Closed
    } derive(Eq,
    Debug
    )

    An output of a step of the protocol state machine (design PROTO-1).

    Output::to_repr

    automatically derived

    Path

    pub struct Path {
    // private fields
    } derive(Eq)

    The place of a value in a payload, for decode errors. The root of a whole payload is $; the arguments of an invocation are arguments. An index adds [n] and a property adds .name, for example arguments[0].userName.
    impl Show for Path

    Path::equal

    fn Path::equal(Path, Path) -> Bool
    automatically derived

    Path::index

    fn Path::index(self : Path, index : Int) -> Path

    The path of the item at index of the array at self.

    Path::key

    fn Path::key(self : Path, key : String) -> Path

    The path of the property key of the object at self.

    Path::named

    fn Path::named(name : String) -> Path

    A root with the name name, for example arguments or result.

    Path::not_equal

    fn Path::not_equal(x : Path, y : Path) -> Bool
    automatically derived

    Path::output

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

    Path::root

    fn Path::root() -> Path

    The root of a payload, written $.

    Path::to_repr

    Path::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    PeerProfile

    pub(all) enum PeerProfile {
    MoonLander
    DotNet10
    DotNet11
    } derive(Eq,
    Debug
    )

    The server that a client talks to. It decides whether the client sends a CancelInvocation for a call with one result: .NET 10 servers do not accept one, .NET 11 servers and Moon-Lander servers do (design WIRE-2).

    PeerProfile::accepts_cancel

    fn PeerProfile::accepts_cancel(self : PeerProfile, kind : CallKind) -> Bool

    True when the peer accepts a CancelInvocation for a call of kind. Every peer accepts one for a stream.

    PeerProfile::equal

    fn PeerProfile::equal(PeerProfile, PeerProfile) -> Bool
    automatically derived

    PeerProfile::not_equal

    fn PeerProfile::not_equal(x : PeerProfile, y : PeerProfile) -> Bool
    automatically derived

    PeerProfile::to_repr

    automatically derived

    ProtocolState

    pub struct ProtocolState {
    // private fields
    }

    The state of one end of a hub connection. It does no I/O: each input gives the next state and a list of outputs (design PROTO-1). The value is immutable, so a test can keep each state of a run.

    ProtocolState::call

    fn ProtocolState::call(self : ProtocolState, mode : CallMode, target : MethodName, arguments : ArrayView[HubValue], uploads? : Int, headers? : Headers) -> (ProtocolState, Invoked, Array[Output]) raise UsageError

    Start a call to the peer with uploads upload streams. The state gives the invocation ID and the stream IDs from one counter, as the .NET and JavaScript clients do.

    ProtocolState::cancel

    fn ProtocolState::cancel(self : ProtocolState, invocation_id : InvocationId) -> (ProtocolState, Array[Output]) raise UsageError

    Ask the peer to cancel a call that this endpoint started. The call stays open until its Completion arrives.

    ProtocolState::client

    fn ProtocolState::client(max_message_size? : SizeLimit) -> (ProtocolState, Array[Output])

    A client end, and the output that sends the handshake request for the JSON protocol.

    ProtocolState::close

    fn ProtocolState::close(self : ProtocolState, error? : String, allow_reconnect? : Bool) -> (ProtocolState, Array[Output])

    Send a Close message and end the connection. error is set only when the connection ends because of an error. A closed connection gives no output.

    ProtocolState::complete

    fn ProtocolState::complete(self : ProtocolState, invocation_id : InvocationId, outcome : Outcome) -> (ProtocolState, Array[Output]) raise UsageError

    Send the Completion of a call that the peer made. A stream call ends with no result or with an error. A cancelled call also gets its Completion.

    ProtocolState::end_upload

    fn ProtocolState::end_upload(self : ProtocolState, stream_id : StreamId, error? : String) -> (ProtocolState, Array[Output]) raise UsageError

    End an upload stream that this endpoint started, with an error text when it ends because of an error.

    ProtocolState::is_closed

    fn ProtocolState::is_closed(self : ProtocolState) -> Bool

    True when the connection is closed.

    ProtocolState::is_open

    fn ProtocolState::is_open(self : ProtocolState) -> Bool

    True when the handshake is complete and the connection is not closed.

    ProtocolState::open_calls

    fn ProtocolState::open_calls(self : ProtocolState) -> Int

    The number of calls that the peer made and that wait for their Completion.

    ProtocolState::open_upload_count

    fn ProtocolState::open_upload_count(self : ProtocolState) -> Int

    The number of upload streams that the peer has not ended.

    ProtocolState::pending_calls

    fn ProtocolState::pending_calls(self : ProtocolState) -> Int

    The number of calls that this endpoint started and that wait for their Completion.

    ProtocolState::ping

    Send a Ping message.

    ProtocolState::receive

    fn ProtocolState::receive(self : ProtocolState, text : StringView) -> (ProtocolState, Array[Output])

    Take the text of one transport frame. A closed connection ignores it.

    ProtocolState::role

    fn ProtocolState::role(self : ProtocolState) -> Role

    The role of the endpoint.

    ProtocolState::send_item

    fn ProtocolState::send_item(self : ProtocolState, invocation_id : InvocationId, item : HubValue) -> (ProtocolState, Array[Output]) raise UsageError

    Send one item of a stream call that the peer made. After the peer cancelled the call, the item is dropped and no output is given.

    ProtocolState::server

    fn ProtocolState::server(max_message_size? : SizeLimit) -> ProtocolState

    A server end that waits for the handshake request. A received message with more bytes than max_message_size closes the connection with an error that names the limit.

    ProtocolState::upload_item

    fn ProtocolState::upload_item(self : ProtocolState, stream_id : StreamId, item : HubValue) -> (ProtocolState, Array[Output]) raise UsageError

    Send one item of an upload stream that this endpoint started.

    Role

    pub(all) enum Role {
    Client
    Server
    } derive(Eq,
    Debug
    )

    The side of a connection.

    Role::equal

    fn Role::equal(Role, Role) -> Bool
    automatically derived

    Role::not_equal

    fn Role::not_equal(x : Role, y : Role) -> Bool
    automatically derived

    Role::to_repr

    automatically derived

    SizeLimit

    pub struct SizeLimit {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A size limit of more than 0 bytes.
    impl Show for SizeLimit

    SizeLimit::bytes

    fn SizeLimit::bytes(bytes : Int) -> SizeLimit raise LimitError

    A size limit of bytes.

    SizeLimit::compare

    fn SizeLimit::compare(SizeLimit, SizeLimit) -> Int
    automatically derived

    SizeLimit::default_message_size

    fn SizeLimit::default_message_size() -> SizeLimit

    The default maximum size of a received hub message of ASP.NET Core SignalR: 32768 bytes.

    SizeLimit::equal

    fn SizeLimit::equal(SizeLimit, SizeLimit) -> Bool
    automatically derived

    SizeLimit::hash

    fn SizeLimit::hash(self : SizeLimit) -> Int
    automatically derived

    SizeLimit::hash_combine

    fn SizeLimit::hash_combine(SizeLimit, Hasher) -> Unit
    automatically derived

    SizeLimit::not_equal

    fn SizeLimit::not_equal(x : SizeLimit, y : SizeLimit) -> Bool
    automatically derived

    SizeLimit::output

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

    SizeLimit::to_bytes

    fn SizeLimit::to_bytes(self : SizeLimit) -> Int

    The limit in bytes.

    SizeLimit::to_repr

    automatically derived

    SizeLimit::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    StreamId

    pub struct StreamId {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The ID of an upload stream. It has the rules of an invocation ID.
    impl Show for StreamId

    StreamId::equal

    fn StreamId::equal(StreamId, StreamId) -> Bool
    automatically derived

    StreamId::from_counter

    fn StreamId::from_counter(value : UInt64) -> StreamId

    The stream ID for a counter value: the decimal text of value.

    StreamId::hash

    fn StreamId::hash(self : StreamId) -> Int
    automatically derived

    StreamId::hash_combine

    fn StreamId::hash_combine(StreamId, Hasher) -> Unit
    automatically derived

    StreamId::not_equal

    fn StreamId::not_equal(x : StreamId, y : StreamId) -> Bool
    automatically derived

    StreamId::output

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

    StreamId::parse

    fn StreamId::parse(text : String) -> StreamId raise IdentifierError

    Parse a stream ID.

    StreamId::to_repr

    automatically derived

    StreamId::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    StreamInvocation

    pub(all) struct StreamInvocation {
    invocation_id : InvocationId
    target : MethodName
    arguments : ReadOnlyArray[HubValue]
    stream_ids : ReadOnlyArray[StreamId]
    headers : Headers
    } derive(Eq,
    Debug
    )

    A StreamInvocation (type 4): a call whose results are StreamItem messages.

    StreamInvocation::equal

    automatically derived

    StreamInvocation::not_equal

    fn StreamInvocation::not_equal(x : StreamInvocation, y : StreamInvocation) -> Bool
    automatically derived

    StreamInvocation::to_repr

    automatically derived

    StreamItem

    pub(all) struct StreamItem {
    invocation_id : InvocationId
    item : HubValue
    headers : Headers
    } derive(Eq,
    Debug
    )

    A StreamItem (type 2): one item of a stream. The ID is an invocation ID for a server stream, or a stream ID for an upload stream.

    StreamItem::equal

    fn StreamItem::equal(StreamItem, StreamItem) -> Bool
    automatically derived

    StreamItem::not_equal

    fn StreamItem::not_equal(x : StreamItem, y : StreamItem) -> Bool
    automatically derived

    StreamItem::to_repr

    automatically derived

    TextFormat

    pub(all) enum TextFormat {
    Base64
    Timestamp
    Integer
    } derive(Eq,
    Debug
    )

    A text form that a codec reads.

    TextFormat::equal

    fn TextFormat::equal(TextFormat, TextFormat) -> Bool
    automatically derived

    TextFormat::not_equal

    fn TextFormat::not_equal(x : TextFormat, y : TextFormat) -> Bool
    automatically derived

    TextFormat::to_repr

    automatically derived

    TimeLimit

    pub struct TimeLimit {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    A time limit of more than 0 milliseconds, for keep-alive, timeouts and the drain.
    impl Show for TimeLimit

    TimeLimit::compare

    fn TimeLimit::compare(TimeLimit, TimeLimit) -> Int
    automatically derived

    TimeLimit::default_client_timeout

    fn TimeLimit::default_client_timeout() -> TimeLimit

    The default client timeout of ASP.NET Core SignalR: 30 seconds.

    TimeLimit::default_drain

    fn TimeLimit::default_drain() -> TimeLimit

    The default time that a graceful drain waits for the open calls: 5 seconds.

    TimeLimit::default_handshake_timeout

    fn TimeLimit::default_handshake_timeout() -> TimeLimit

    The default handshake timeout of ASP.NET Core SignalR: 15 seconds.

    TimeLimit::default_keep_alive

    fn TimeLimit::default_keep_alive() -> TimeLimit

    The default keep-alive interval of ASP.NET Core SignalR: 15 seconds.

    TimeLimit::equal

    fn TimeLimit::equal(TimeLimit, TimeLimit) -> Bool
    automatically derived

    TimeLimit::hash

    fn TimeLimit::hash(self : TimeLimit) -> Int
    automatically derived

    TimeLimit::hash_combine

    fn TimeLimit::hash_combine(TimeLimit, Hasher) -> Unit
    automatically derived

    TimeLimit::milliseconds

    fn TimeLimit::milliseconds(milliseconds : Int64) -> TimeLimit raise LimitError

    A time limit of milliseconds.

    TimeLimit::not_equal

    fn TimeLimit::not_equal(x : TimeLimit, y : TimeLimit) -> Bool
    automatically derived

    TimeLimit::output

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

    TimeLimit::seconds

    fn TimeLimit::seconds(seconds : Int) -> TimeLimit raise LimitError

    A time limit of seconds.

    TimeLimit::to_milliseconds

    fn TimeLimit::to_milliseconds(self : TimeLimit) -> Int64

    The limit in milliseconds.

    TimeLimit::to_repr

    automatically derived

    TimeLimit::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    TimerAction

    pub(all) enum TimerAction {
    WaitUntil(Int64)
    SendPing
    TimedOut
    HandshakeTimedOut
    } derive(Eq,
    Debug
    )

    What a connection must do now for its time limits.

    TimerAction::equal

    fn TimerAction::equal(TimerAction, TimerAction) -> Bool
    automatically derived

    TimerAction::not_equal

    fn TimerAction::not_equal(x : TimerAction, y : TimerAction) -> Bool
    automatically derived

    TimerAction::to_repr

    automatically derived

    Timestamp

    pub struct Timestamp {
    // private fields
    } derive(Compare, Eq, Hash)

    An instant in UTC with a precision of 100 nanoseconds, from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.9999999Z. The JSON encoding writes it as ISO 8601 text in UTC, as System.Text.Json writes a UTC DateTime.
    impl Show for Timestamp

    Timestamp::compare

    fn Timestamp::compare(Timestamp, Timestamp) -> Int
    automatically derived

    Timestamp::equal

    fn Timestamp::equal(Timestamp, Timestamp) -> Bool
    automatically derived

    Timestamp::from_unix

    fn Timestamp::from_unix(seconds : Int64, nanoseconds? : Int) -> Timestamp raise TimestampError

    The timestamp seconds after the Unix epoch plus nanoseconds. The nanoseconds must be a multiple of 100 from 0 to 999999900.

    Timestamp::hash

    fn Timestamp::hash(self : Timestamp) -> Int
    automatically derived

    Timestamp::hash_combine

    fn Timestamp::hash_combine(Timestamp, Hasher) -> Unit
    automatically derived

    Timestamp::nanoseconds

    fn Timestamp::nanoseconds(self : Timestamp) -> Int

    The nanoseconds after unix_seconds, a multiple of 100.

    Timestamp::not_equal

    fn Timestamp::not_equal(x : Timestamp, y : Timestamp) -> Bool
    automatically derived

    Timestamp::output

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

    The ISO 8601 text in UTC: YYYY-MM-DDTHH:MM:SS, a fraction with no trailing zeros when the nanoseconds are not 0, and Z.

    Timestamp::parse

    fn Timestamp::parse(text : String) -> Timestamp raise TimestampError

    Parse an RFC 3339 timestamp with a Z or a numeric offset, for example 2026-12-01T10:15:00Z or 2026-12-01T11:15:00.5+01:00. A text with no offset is an error, because it does not give one instant.

    Timestamp::to_repr

    Timestamp::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    Timestamp::unix_seconds

    fn Timestamp::unix_seconds(self : Timestamp) -> Int64

    The seconds after the Unix epoch, rounded down.

    TimestampField

    pub(all) enum TimestampField {
    Year
    Month
    Day
    Hour
    Minute
    Second
    OffsetHour
    OffsetMinute
    } derive(Eq,
    Debug
    )

    A field of a timestamp text.

    TimestampField::equal

    automatically derived

    TimestampField::not_equal

    fn TimestampField::not_equal(x : TimestampField, y : TimestampField) -> Bool
    automatically derived

    TimestampField::to_repr

    automatically derived

    TimestampRule

    pub(all) enum TimestampRule {
    Syntax
    FieldOutOfRange(TimestampField)
    TooPrecise
    InvalidNanoseconds(Int)
    OutOfRange
    } derive(Eq,
    Debug
    )

    The rule of a timestamp that a text or a value breaks.

    TimestampRule::equal

    automatically derived

    TimestampRule::not_equal

    fn TimestampRule::not_equal(x : TimestampRule, y : TimestampRule) -> Bool
    automatically derived

    TimestampRule::to_repr

    automatically derived

    TransferFormat

    pub(all) enum TransferFormat {
    Text
    Binary
    Other(String)
    } derive(Eq,
    Debug
    )

    A transfer format of a transport.

    TransferFormat::equal

    automatically derived

    TransferFormat::name

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

    The name of the format in negotiate payloads.

    TransferFormat::not_equal

    fn TransferFormat::not_equal(x : TransferFormat, y : TransferFormat) -> Bool
    automatically derived

    TransferFormat::to_repr

    automatically derived

    TransportKind

    pub(all) enum TransportKind {
    WebSockets
    ServerSentEvents
    LongPolling
    Other(String)
    } derive(Eq,
    Debug
    )

    A transport of the SignalR connection protocol.

    TransportKind::equal

    automatically derived

    TransportKind::name

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

    The name of the transport in negotiate payloads.

    TransportKind::not_equal

    fn TransportKind::not_equal(x : TransportKind, y : TransportKind) -> Bool
    automatically derived

    TransportKind::to_repr

    automatically derived

    UserId

    pub struct UserId {
    // private fields
    } derive(Eq, Hash,
    Debug
    )

    The ID of a user, from the identity of a connection. It has 1 to 256 characters and no control characters.
    impl Show for UserId

    UserId::equal

    fn UserId::equal(UserId, UserId) -> Bool
    automatically derived

    UserId::hash

    fn UserId::hash(self : UserId) -> Int
    automatically derived

    UserId::hash_combine

    fn UserId::hash_combine(UserId, Hasher) -> Unit
    automatically derived

    UserId::not_equal

    fn UserId::not_equal(x : UserId, y : UserId) -> Bool
    automatically derived

    UserId::output

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

    UserId::parse

    fn UserId::parse(text : String) -> UserId raise IdentifierError

    Parse a user ID.

    UserId::to_repr

    automatically derived

    UserId::to_string

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

    Default implementation for Show::to_string, uses a StringBuilder

    ValueKind

    pub(all) enum ValueKind {
    Null
    Bool
    Integer
    Double
    String
    Bytes
    Timestamp
    Array
    Map
    } derive(Eq,
    Debug
    )

    The kind of a payload value, for error texts.

    ValueKind::equal

    fn ValueKind::equal(ValueKind, ValueKind) -> Bool
    automatically derived

    ValueKind::label

    fn ValueKind::label(self : ValueKind) -> String

    The name of the kind for people, for example an integer.

    ValueKind::not_equal

    fn ValueKind::not_equal(x : ValueKind, y : ValueKind) -> Bool
    automatically derived

    ValueKind::to_repr

    automatically derived

    access_token_length_limit

    let access_token_length_limit : Int

    The limit of the length of an access token.

    args0

    fn args0() -> Arguments[Unit]

    No parameters.

    args1

    fn[A] args1(a : Codec[A]) -> Arguments[A]

    One parameter.

    args2

    fn[A, B] args2(a : Codec[A], b : Codec[B]) -> Arguments[(A, B)]

    Two parameters.

    args3

    fn[A, B, C] args3(a : Codec[A], b : Codec[B], c : Codec[C]) -> Arguments[(A, B, C)]

    Three parameters.

    args4

    fn[A, B, C, D] args4(a : Codec[A], b : Codec[B], c : Codec[C], d : Codec[D]) -> Arguments[(A, B, C, D)]

    Four parameters.

    array

    fn[T] array(codec : Codec[T]) -> Codec[Array[T]]

    An array with items of one type.

    bool

    fn bool() -> Codec[Bool]

    A boolean.

    bytes

    fn bytes() -> Codec[Bytes]

    Bytes. The JSON encoding writes them as Base64 text with padding, so decode also reads Base64 text.

    camel_case

    fn camel_case(name : String) -> String

    The camelCase form of a field name. A snake_case name joins its words: user_name gives userName. Another name gets the camelCase policy of System.Text.Json: UserName gives userName, and URLValue gives urlValue. Only ASCII letters change, because the MoonBit core library has no Unicode case conversion; give the property name for a name that starts with another letter.

    double

    fn double() -> Codec[Double]

    A finite double. Encode raises NotFinite for NaN and infinity, as System.Text.Json does by default. Decode also reads an integer.

    enum_names

    fn[T : Eq + Show] enum_names(mapping : EnumMapping[T, String]) -> Codec[T]

    An enum as the text that mapping gives for each case. This is an explicit choice, as JsonStringEnumConverter is in .NET. Decode looks for an equal text first, and then matches with no regard to the case of ASCII letters.

    enum_numbers

    fn[T : Eq + Show] enum_numbers(mapping : EnumMapping[T, Int]) -> Codec[T]

    An enum as the number that mapping gives for each case. Use it when the .NET enum has explicit values.

    enumeration

    fn[T : Eq + Show] enumeration(cases : Array[T]) -> Codec[T]

    An enum as the number of its position in cases: the first case is 0, the second case is 1. This is the default of System.Text.Json for a .NET enum with no explicit values.

    field

    fn[R, F] field(name : String, codec : Codec[F], get : (R) -> F, property? : String) -> Field[R, F]

    A record property for the field name. The property name is the camelCase form of name, the default of System.Text.Json Web. Give property to use another property name; that is an explicit choice.

    frame

    fn frame(text : StringView) -> String

    The text of one message followed by the record separator.

    hub_value

    fn hub_value() -> Codec[HubValue]

    The codec of a payload value itself.

    id_length_limit

    let id_length_limit : Int

    The limit of the length of the IDs that a peer chooses: invocation IDs and stream IDs (design PROTO-2).

    int

    fn int() -> Codec[Int]

    A 32-bit integer as a number.

    int64

    fn int64() -> Codec[Int64]

    A 64-bit integer as a number, only from -(2^53 - 1) to 2^53 - 1, so that a JavaScript client reads it exactly. Encode and decode raise IntegerOutOfRange with the safe range for another value. Use int64_as_text for the full range.

    int64_as_text

    fn int64_as_text() -> Codec[Int64]

    A 64-bit integer as decimal text, for the full range of Int64. Decode also reads a number. This is an explicit choice, as JsonNumberHandling.WriteAsString is in .NET.

    max_safe_integer

    let max_safe_integer : Int64

    The largest integer that a JavaScript number holds exactly: 2^53 - 1.

    name_length_limit

    let name_length_limit : Int

    The limit of the length of names and of the IDs that a server gives.

    option

    fn[T] option(codec : Codec[T]) -> Codec[T?]

    None as null and Some(value) as the value. A value that encodes as null, such as the None of a nested option, raises NullInOption, because a decode could not tell it from None. A missing record property decodes to None.

    record1

    fn[R, A] record1(make : (A) -> R raise?, a : Field[R, A]) -> Codec[R]

    A record with one field as an object. Decode ignores properties that it does not know.

    record2

    fn[R, A, B] record2(make : (A, B) -> R raise?, a : Field[R, A], b : Field[R, B]) -> Codec[R]

    A record with two fields as an object.

    record3

    fn[R, A, B, C] record3(make : (A, B, C) -> R raise?, a : Field[R, A], b : Field[R, B], c : Field[R, C]) -> Codec[R]

    A record with three fields as an object.

    record4

    fn[R, A, B, C, D] record4(make : (A, B, C, D) -> R raise?, a : Field[R, A], b : Field[R, B], c : Field[R, C], d : Field[R, D]) -> Codec[R]

    A record with four fields as an object.

    record5

    fn[R, A, B, C, D, E] record5(make : (A, B, C, D, E) -> R raise?, a : Field[R, A], b : Field[R, B], c : Field[R, C], d : Field[R, D], e : Field[R, E]) -> Codec[R]

    A record with five fields as an object.

    record6

    fn[R, A, B, C, D, E, F] record6(make : (A, B, C, D, E, F) -> R raise?, a : Field[R, A], b : Field[R, B], c : Field[R, C], d : Field[R, D], e : Field[R, E], f : Field[R, F]) -> Codec[R]

    A record with six fields as an object.

    record_separator

    let record_separator : Char

    The record separator 0x1E that ends each message of the JSON hub protocol.

    redact_target

    fn redact_target(target : String) -> String

    A request target with each id and access_token query value replaced by [REDACTED], for a log line. The value of id is the connection token.

    string

    fn string() -> Codec[String]

    A string.

    timestamp

    fn timestamp() -> Codec[Timestamp]

    A timestamp. The JSON encoding writes it as ISO 8601 text, so decode also reads that text.

    tuple2

    fn[A, B] tuple2(a : Codec[A], b : Codec[B]) -> Codec[(A, B)]

    Two values as an array of two items, in order. Use it for the arguments of a method with two parameters: a different number of arguments raises LengthMismatch with both numbers.

    tuple3

    fn[A, B, C] tuple3(a : Codec[A], b : Codec[B], c : Codec[C]) -> Codec[(A, B, C)]

    Three values as an array of three items, in order.

    tuple4

    fn[A, B, C, D] tuple4(a : Codec[A], b : Codec[B], c : Codec[C], d : Codec[D]) -> Codec[(A, B, C, D)]

    Four values as an array of four items, in order.

    uint64

    fn uint64() -> Codec[UInt64]

    An unsigned 64-bit integer as a number, only from 0 to 2^53 - 1. Use uint64_as_text for the full range.

    uint64_as_text

    fn uint64_as_text() -> Codec[UInt64]

    An unsigned 64-bit integer as decimal text, for the full range of UInt64. Decode also reads a number.

    unit

    fn unit() -> Codec[Unit]

    () as null. Use it for a method with no result.

    utf8_length

    fn utf8_length(text : StringView) -> Int

    The number of UTF-8 bytes of text.