moonbitstack/moonasgi/conform does not have a README file

    ConformanceReport

    pub(all) struct ConformanceReport {
    total : Int
    passed : Int
    failures : Array[String]
    } derive(Eq)

    The outcome of the ASGI 3.0 conformance harness: how many round-trip checks ran, how many passed, and the names of any that failures. A clean run has an empty failures. Reusable beyond the test suite — a server or framework built on the seam can call run_conformance to self-verify the wiring.

    ConformanceReport::equal

    ConformanceReport::not_equal

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

    ConformanceReport::ok

    fn ConformanceReport::ok(self : ConformanceReport) -> Bool

    Whether every conformance check passed (no failures recorded).

    EventOrderError

    pub(all) enum EventOrderError {
    BodyBeforeStart
    DuplicateResponseStart
    EarlyHintAfterStart
    BodyAfterComplete
    UnexpectedTrailers
    TrailersBeforeBody
    MissingResponseStart
    IncompleteBody
    MissingTrailers
    EventAfterComplete
    DebugAfterStart
    DuplicateDebug
    PushBeforeStart
    PathSendMixedWithBody
    IllegalResponseHeader
    FrameBeforeAccept
    DuplicateAccept
    EventAfterClose
    DenialBodyBeforeStart
    DenialAfterAccept
    AcceptAfterDenial
    IncompleteDenial
    MissingHandshakeReply
    DuplicateLifespanReply
    ShutdownBeforeStartup
    NonResponseEvent
    } derive(Eq)

    Why an outbound event stream is malformed. ASGI pins the order an application may emit messages in — a body before the response starts, a second start, a websocket frame before the handshake is accepted, and so on are all protocol violations. validate_events walks a stream and names the first violation it finds; a well-formed stream returns None. A server can run this over its own emissions to catch a buggy app early, and the conformance harness drives a negative table through it.

    EventOrderError::describe

    fn EventOrderError::describe(self : EventOrderError) -> String

    A one-line human description of the violation, used in conformance failure names and server logs.

    EventOrderError::equal

    EventOrderError::not_equal

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

    run_conformance

    fn run_conformance() -> ConformanceReport

    Run the ASGI 3.0 conformance harness: a table-driven battery that drives every @spec.Event variant and every Scope field through @http.run_http, ws_run, and the @client.TestClient, asserting round-trip fidelity — a value put in comes back unchanged, and no two distinct events or scope shapes are confused — and a negative table that asserts validate_events rejects every malformed ordering (a body before the response starts, a websocket frame before the handshake, a lifespan shutdown reply before startup, and the rest) with the exact violation. Returns a ConformanceReport naming any check that failed, so the suite (and any downstream server) can assert ok().

    validate_events

    Validate an outbound event stream against the ordering rules for its scope, dispatching to the http / websocket / lifespan validator. The public entry a server calls to check an application's emissions before writing them to the wire.

    validate_http_response

    fn validate_http_response(events : Array[
    Event
    ]) -> EventOrderError?

    Validate the outbound event stream an application emits for an http request, against ASGI's http response ordering: at most one HttpResponseStart, no body or pathsend/zerocopysend before it, early hints only ahead of it, a body stream that terminates once (more_body: false), trailers only when the start promised them and only after the body completes, and nothing after the response is fully sent. HttpResponseDebug must come once and before the start; HttpResponsePush only after it; HttpResponsePathSend cannot be mixed with a body. Returns the first violation, or None for a well-formed complete response.

    validate_inbound

    Check an inbound event an application is about to act on. ASGI requires exactly one of bytes or text to be set on a websocket.receive, and a frame that sets neither, or both, is a server bug the application should not have to guess about. Returns None for a well-formed event.

    validate_lifespan_replies

    fn validate_lifespan_replies(events : Array[
    Event
    ]) -> EventOrderError?

    Validate the outbound replies an application emits for a lifespan run: a startup reply (LifespanStartupComplete / LifespanStartupFailed) before a shutdown reply (LifespanShutdownComplete / LifespanShutdownFailed), each phase answered at most once. Returns the first violation, or None.

    validate_ws_response

    fn validate_ws_response(events : Array[
    Event
    ]) -> EventOrderError?

    Validate the outbound event stream an application emits for a websocket connection, against ASGI's handshake ordering: the connect must be answered with an WebSocketAccept, a WebSocketClose, or a denial (WebSocketHttpResponseStart + body); frames are only legal once accepted; nothing follows a close or a completed denial; a denial cannot mix with an accept. Returns the first violation, or None for a well-formed stream.