Warky Devs

Warky Devs

Vanderbijlpark, South Africa

modelgate (1.4.1)

Published 2026-10-14 20:11:33 +00:00 by warkanum

Installation

[registry]
default = "gitea"

[registries.gitea]
index = "sparse+https://git.warky.dev/api/packages/wdevs/cargo/" # Sparse index
# index = "https://git.warky.dev/wdevs/_cargo-index.git" # Git

[net]
git-fetch-with-cli = true
cargo add modelgate@1.4.1

About this package

Client for PostAPI (JSON body) and FunctionAPI endpoints

modelgate (Rust)

Rust client for PostAPI (JSON body) and FunctionAPI. Async (reqwest + tokio). MSRV 1.80.

Clients

Type Constructor Methods
PostAPIClient new(base_url) / from_builder(ClientBuilder) get_metadata read create update delete
FunctionAPIClient new(base_url) / from_builder(ClientBuilder) query query_list request

ClientBuilder::new(url).token().header().timeout().http_client(). Precedence: Content-Type < custom headers < bearer token.

PostAPI

  • RecordId: Int/Str → URL, Many(Vec<String>) → body (From impls provided).
  • Options (Default + struct update), optional fields are Option/empty Vec.
  • Result: Response{success, data: serde_json::Value, metadata}; resp.decode::<T>().

FunctionAPI

  • Routes are server-defined: pass the path.
  • Params = BTreeMap<String, Param> → query string (Param::List → repeated keys).
  • FunctionAPIOptions → X-* headers: filters, search_filters, custom_sql_where, custom_sql_or, sort, limit, offset, distinct, skip_count, skip_cache, response_format.
  • query_list fills metadata from Content-Range; 206 is success.

Server quirks

  • sort is raw SQL in ORDER BY (client sends col ASC|DESC).
  • One search operator per column.
  • Values starting ZIP_ / __ are base64-decoded by the server.
  • Non-ASCII, control chars and edge spaces are auto-encoded (ZIP_).

Errors

Error::Api { status, message, error: ApiError{code, message, detail, sql} }, Error::Http, Error::Json.

Test

cargo test

Dependencies

ID Version
base64 ^0.22
reqwest ^0.12
serde ^1
serde_json ^1
thiserror ^1
tokio ^1
wiremock ^0.6
Details
Cargo
2026-10-14 20:11:33 +00:00
0
MIT
20 KiB
Assets (1)
Versions (1) View all
1.4.1 2026-10-14