Trait backtalk::Adapter
[−]
[src]
pub trait Adapter: Send + Sync { fn list(
&self,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>; fn get(
&self,
id: &str,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>; fn post(
&self,
data: &JsonObject,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>; fn patch(
&self,
id: &str,
data: &JsonObject,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>; fn delete(
&self,
id: &str,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>; fn handle(&self, req: Request) -> BoxFuture<Reply, Error> { ... } }
Converts a Request to a static Reply from a database.
An Adapter
talks to a database. If you're using an Adapter
, and not implementing your own, you
probably just want to use the handle
function. By implementing the five functions list
, get
,
post
, patch
and delete
, an Adapter
gets the handle
function for free.
You most likely won't want to implement your own Adapter, since these are generic and don't contain
project-specific code. Backtalk implements memory::MemoryAdapter
for development, but you will
hopefully eventually be able to find third-party adapters for various databases in other crates.
Required Methods
fn list(
&self,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
&self,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
fn get(
&self,
id: &str,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
&self,
id: &str,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
fn post(
&self,
data: &JsonObject,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
&self,
data: &JsonObject,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
fn patch(
&self,
id: &str,
data: &JsonObject,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
&self,
id: &str,
data: &JsonObject,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
fn delete(
&self,
id: &str,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
&self,
id: &str,
params: &JsonObject
) -> BoxFuture<JsonObject, (ErrorKind, JsonValue)>
Provided Methods
fn handle(&self, req: Request) -> BoxFuture<Reply, Error>
Takes a Request
, passes it to the appropriate function, and turns the response into a proper
Reply
future. If you're using an Adapter
in your webapp, this is the function you want to
call.
Implementors
impl Adapter for MemoryAdapter