All files

src/stdlib/http_runtime.panack

Green: covered; red: known zero; amber: unavailable. Blank lines are outside the executable-start-line denominator.

    1 // Implementation bridge for the routed HTTP package; no general mutable cell.
    2 // T and H stay associated with the same unforgeable runtime state.
    3 pub create[T,H](address: Str, port: Nat, context: T): HttpServerState[T,H] {
    4   http_state_create(address, port, context)
    5 }
    6 
    7 pub pure context[T,H](state: HttpServerState[T,H]): T { http_state_context(state) }
    8 
    9 pub setup_error[T,H](state: HttpServerState[T,H]): Option[Str] { http_state_setup_error(state) }
   10 
   11 pub invalid_route[T,H](state: HttpServerState[T,H]): Unit { http_state_fail_setup(state) }
   12 
   13 pub register[T,H](state: HttpServerState[T,H], method: Str, path: Str, handler: H): Unit {
   14   http_state_register(state, method, path, handler)
   15 }
   16 
   17 pub writer_get_status(state: HttpResponseState): Nat { http_writer_get_status(state) }
   18 pub writer_get_headers(state: HttpResponseState): [[Str]] { http_writer_get_headers(state) }
   19 pub writer_reject(state: HttpResponseState): Unit { http_writer_reject(state) }
   20 pub writer_status(state: HttpResponseState, status: Nat): Unit { http_writer_status(state, status) }
   21 pub writer_headers(state: HttpResponseState, headers: [[Str]]): Unit { http_writer_headers(state, headers) }
   22 pub writer_commit(state: HttpResponseState, wire: Bytes): Unit { http_writer_commit(state, wire) }
   23 
   24 pub connection_writer[R,W](connection: HttpConnectionState[R,W]): HttpResponseState { http_connection_writer(connection) }
   25 pub connection_routes[R,W](connection: HttpConnectionState[R,W]): [[Str]] { http_connection_routes(connection) }
   26 pub connection_fallback[R,W](connection: HttpConnectionState[R,W]): Bool { http_connection_fallback(connection) }
   27 pub connection_admit[R,W](connection: HttpConnectionState[R,W]): Bool { http_connection_admit(connection) }
   28 pub async connection_invoke[R,W](connection: HttpConnectionState[R,W], route: Option[Nat], request: R, writer: W): Result[Unit,Str] {
   29   await http_connection_invoke(connection, route, request, writer)
   30 }
   31 
   32 pub async listen_ordinary[R,W](state: HttpServerState[Unit,AsyncFn[R,W,Result[Unit,Str]]], worker: AsyncFn[HttpConnectionState[R,W],Result[Unit,Str]]): Result[Unit,Str] {
   33   await http_listen_ordinary(state, worker)
   34 }
   35 pub async listen_contextual[T,R,W](state: HttpServerState[T,AsyncFn[T,R,W,Result[Unit,Str]]], worker: AsyncFn[HttpConnectionState[R,W],Result[Unit,Str]]): Result[Unit,Str] {
   36   await http_listen_contextual(state, worker)
   37 }
   38 pub async close[T,H](state: HttpServerState[T,H]): Result[Unit,Str] { await http_close(state) }
   39 pub async destroy[T,H](state: HttpServerState[T,H]): Result[Unit,Str] { await http_destroy(state) }
   40 
   41 pub pure bytes_slice(data: Bytes, start: Nat, end: Nat): Bytes { http_bytes_slice(data, start, end) }
   42 pub body[R,W](connection: HttpConnectionState[R,W]): Bytes { http_body(connection) }
   43 pub body_size[R,W](connection: HttpConnectionState[R,W]): Nat { http_body_size(connection) }
   44 pub body_append[R,W](connection: HttpConnectionState[R,W], data: Bytes, start: Nat, end: Nat): Bool { http_body_append(connection, data, start, end) }
   45 pub async connection_continue[R,W](connection: HttpConnectionState[R,W]): Result[Unit,Str] {
   46   match await http_connection_continue(connection) { Ok(done) => Ok(()), Error(problem) => Error(problem) }
   47 }
   48 

Functions

[
  {
    "id": "declaration/0",
    "name": "create",
    "line": 3,
    "state": "covered",
    "entries": "15"
  },
  {
    "id": "declaration/1",
    "name": "context",
    "line": 7,
    "state": "covered",
    "entries": "2"
  },
  {
    "id": "declaration/2",
    "name": "setup_error",
    "line": 9,
    "state": "covered",
    "entries": "7"
  },
  {
    "id": "declaration/3",
    "name": "invalid_route",
    "line": 11,
    "state": "covered",
    "entries": "1"
  },
  {
    "id": "declaration/4",
    "name": "register",
    "line": 13,
    "state": "covered",
    "entries": "29"
  },
  {
    "id": "declaration/5",
    "name": "writer_get_status",
    "line": 17,
    "state": "covered",
    "entries": "21"
  },
  {
    "id": "declaration/6",
    "name": "writer_get_headers",
    "line": 18,
    "state": "covered",
    "entries": "21"
  },
  {
    "id": "declaration/7",
    "name": "writer_reject",
    "line": 19,
    "state": "covered",
    "entries": "3"
  },
  {
    "id": "declaration/8",
    "name": "writer_status",
    "line": 20,
    "state": "covered",
    "entries": "3"
  },
  {
    "id": "declaration/9",
    "name": "writer_headers",
    "line": 21,
    "state": "covered",
    "entries": "6"
  },
  {
    "id": "declaration/10",
    "name": "writer_commit",
    "line": 22,
    "state": "covered",
    "entries": "31"
  },
  {
    "id": "declaration/11",
    "name": "connection_writer",
    "line": 24,
    "state": "covered",
    "entries": "38"
  },
  {
    "id": "declaration/12",
    "name": "connection_routes",
    "line": 25,
    "state": "covered",
    "entries": "29"
  },
  {
    "id": "declaration/13",
    "name": "connection_fallback",
    "line": 26,
    "state": "covered",
    "entries": "29"
  },
  {
    "id": "declaration/14",
    "name": "connection_admit",
    "line": 27,
    "state": "covered",
    "entries": "20"
  },
  {
    "id": "declaration/15",
    "name": "connection_invoke",
    "line": 28,
    "state": "covered",
    "entries": "19"
  },
  {
    "id": "declaration/16",
    "name": "listen_ordinary",
    "line": 32,
    "state": "covered",
    "entries": "11"
  },
  {
    "id": "declaration/17",
    "name": "listen_contextual",
    "line": 35,
    "state": "zero",
    "entries": "0"
  },
  {
    "id": "declaration/18",
    "name": "close",
    "line": 38,
    "state": "covered",
    "entries": "5"
  },
  {
    "id": "declaration/19",
    "name": "destroy",
    "line": 39,
    "state": "covered",
    "entries": "4"
  },
  {
    "id": "declaration/20",
    "name": "bytes_slice",
    "line": 41,
    "state": "covered",
    "entries": "459"
  },
  {
    "id": "declaration/21",
    "name": "body",
    "line": 42,
    "state": "covered",
    "entries": "19"
  },
  {
    "id": "declaration/22",
    "name": "body_size",
    "line": 43,
    "state": "covered",
    "entries": "26"
  },
  {
    "id": "declaration/23",
    "name": "body_append",
    "line": 44,
    "state": "covered",
    "entries": "21"
  },
  {
    "id": "declaration/24",
    "name": "connection_continue",
    "line": 45,
    "state": "covered",
    "entries": "3"
  }
]

Source branch outcomes

[
  {
    "id": "declaration/24/tail/arm/0",
    "outcome": "Ok",
    "line": 46,
    "state": "covered",
    "hits": "3"
  },
  {
    "id": "declaration/24/tail/arm/1",
    "outcome": "Error",
    "line": 46,
    "state": "zero",
    "hits": "0"
  }
]

Reviewed declaration exclusions

[]