pub trait Api:
Serialize
+ for<'de> Deserialize<'de>
+ Send
+ Sync
+ Debug
+ 'static {
type Response: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + Debug;
type Error: ApiError;
// Required method
fn name() -> ApiName;
}Expand description
An API request type. This trait is used by BonsaiDb’s server to allow a
client to send a request of this type, and the server can respond with a
Result<Api::Response,Api::Error>.
§Deriving this trait
This trait can be derived. The only required attribute is name:
name = "api-name"orname = "api-name", authority = "api-authority": Configures the Api’s fully qualified name. This name must be unique across all other Apis installed. When creating an Api that is meant to be reused, ensure that a unique authority is used to prevent name collisions.response = ResponseType: Configures theApi::Responseassociated type. This is the type that the handler will return upon success. If not specified,()is used.error = ErrorType: Configures theApi::Errorassociated type. This is the type that the handler will return upon error. If not specified,Infallibleis used.
use bonsaidb_core::api::Api;
use serde::{Deserialize, Serialize};
#[derive(Api, Debug, Serialize, Deserialize)]
#[api(name = "list-records", response = Vec<Record>)]
struct ListRecords {
starting_id: u64,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
struct Record {
title: String,
}Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl Api for ApplyTransaction
impl Api for ApplyTransaction
Source§impl Api for Authenticate
Available on crate features password-hashing or token-authentication only.
impl Api for Authenticate
Available on crate features
password-hashing or token-authentication only.Source§impl Api for ListAvailableSchemas
impl Api for ListAvailableSchemas
Source§impl Api for ListExecutedTransactions
impl Api for ListExecutedTransactions
Source§impl Api for QueryWithDocs
impl Api for QueryWithDocs
Source§impl Api for ReduceGrouped
impl Api for ReduceGrouped
Source§impl Api for SetUserPassword
Available on crate feature password-hashing only.
impl Api for SetUserPassword
Available on crate feature
password-hashing only.