feat: update according to spec

This commit is contained in:
Strix 2023-10-14 22:39:51 +02:00
parent a28e7b57a2
commit e4fe3c5779
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774

View file

@ -1,27 +1,45 @@
use reqwest::blocking::Response; use std::collections::HashMap;
pub struct APITransaction<R = Response> { enum Query {
/// Query made to API. Pull {
query: String, //TODO: enum name: String,
/// Response struct from abstracted library version: Option<u128>,
_response: Option<R> tags: Vec<String>
} },
Push {
impl<R> APITransaction<R> { _data: Vec<u8>
pub fn new(_response: Option<R>) -> Self {
APITransaction {
query: String::default(),
_response
}
} }
} }
pub struct API { struct Request {
base_url: String, version: u32,
id: String,
token: Option<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>
} }