Skip to main content

Module response

Module response 

Source
Expand description

Generic API response envelope types.

ApiResponse<T> wraps any payload with consistent metadata so all API endpoints share the same top-level shape.

{
  "data": { "id": "abc", "name": "Foo" },
  "meta": {
    "request_id": "req-123",
    "timestamp": "2026-04-06T19:00:00Z",
    "version": "1.4.0"
  },
  "links": [{ "rel": "self", "href": "/resources/abc" }]
}

§Builder example

use api_bones::response::{ApiResponse, ResponseMeta};

let response: ApiResponse<&str> = ApiResponse::builder("hello world")
    .meta(ResponseMeta::new().request_id("req-001").version("1.0"))
    .build();

assert_eq!(response.data, "hello world");

Structs§

ApiResponse
Generic API response envelope.
ApiResponseBuilder
Builder for ApiResponse.
ResponseMeta
Metadata attached to every ApiResponse.