feat: update according to spec
This commit is contained in:
parent
a28e7b57a2
commit
e4fe3c5779
1 changed files with 36 additions and 18 deletions
|
@ -1,27 +1,45 @@
|
|||
use reqwest::blocking::Response;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct APITransaction<R = Response> {
|
||||
/// Query made to API.
|
||||
query: String, //TODO: enum
|
||||
/// Response struct from abstracted library
|
||||
_response: Option<R>
|
||||
}
|
||||
|
||||
impl<R> APITransaction<R> {
|
||||
pub fn new(_response: Option<R>) -> Self {
|
||||
APITransaction {
|
||||
query: String::default(),
|
||||
_response
|
||||
}
|
||||
enum Query {
|
||||
Pull {
|
||||
name: String,
|
||||
version: Option<u128>,
|
||||
tags: Vec<String>
|
||||
},
|
||||
Push {
|
||||
_data: Vec<u8>
|
||||
}
|
||||
}
|
||||
|
||||
pub struct API {
|
||||
base_url: String,
|
||||
struct Request {
|
||||
version: u32,
|
||||
id: String,
|
||||
token: Option<String>,
|
||||
history: Vec<APITransaction>
|
||||
query: HashMap<String, Query>
|
||||
}
|
||||
|
||||
impl API {
|
||||
struct DataErrorDetails {
|
||||
actor: String,
|
||||
detailed_cause: String,
|
||||
recovery_options: Vec<String>,
|
||||
}
|
||||
|
||||
struct DataError {
|
||||
name: String,
|
||||
cause: Option<String>,
|
||||
details: Option<DataErrorDetails>
|
||||
}
|
||||
|
||||
enum Data {
|
||||
Pull {
|
||||
_data: Option<Vec<u8>>,
|
||||
}
|
||||
}
|
||||
|
||||
struct Response {
|
||||
version: u32,
|
||||
id: String,
|
||||
reply_to: String,
|
||||
errors: HashMap<String, DataError>,
|
||||
data: HashMap<String, Data>
|
||||
}
|
Loading…
Reference in a new issue