rocksky/xrpc

Raw XRPC transport and decoding helpers for the generated rocksky/api.

Types

pub opaque type Client
pub type Error {
  TransportError(String)
  HttpError(status: Int, body: BitArray)
  DecodeError(json.DecodeError)
}

Constructors

  • TransportError(String)
  • HttpError(status: Int, body: BitArray)
  • DecodeError(json.DecodeError)
pub type Method {
  Get
  Post
}

Constructors

  • Get
  • Post
pub type RawResponse {
  RawResponse(status: Int, body: BitArray)
}

Constructors

  • RawResponse(status: Int, body: BitArray)

Values

pub fn new() -> Client
pub fn raw(
  client: Client,
  method: Method,
  nsid: String,
  params: json.Json,
  body: option.Option(json.Json),
) -> Result(RawResponse, Error)

Escape hatch. Preserves status and raw bytes, including non-2xx responses. Query arrays become repeated URL parameters. A POST body is independent of params.

pub fn request(
  client: Client,
  method: Method,
  nsid: String,
  params: json.Json,
  body: option.Option(json.Json),
  decoder: decode.Decoder(a),
) -> Result(a, Error)

Custom typed call: supply your own decoder for endpoints outside the generated API.

pub fn request_bytes(
  client: Client,
  method: Method,
  nsid: String,
  params: json.Json,
  body: option.Option(json.Json),
) -> Result(BitArray, Error)
pub fn with_endpoint(client: Client, endpoint: String) -> Client
pub fn with_timeout(client: Client, timeout_ms: Int) -> Client
pub fn with_token(client: Client, token: String) -> Client
✨ Search Document