banana_rust_sdk/
types.rs

1use std::time::SystemTimeError;
2use thiserror::Error;
3use serde::{Serialize, Deserialize};
4use serde_json::Value;
5
6#[derive(Serialize, Deserialize, Debug)]
7#[serde(rename_all = "camelCase")]
8pub struct Payload {
9    pub id: String,
10    pub created: usize,
11    pub api_key: String,
12    pub model_key: String,
13    pub model_inputs: Value,
14    pub start_only: bool
15}
16
17#[derive(Serialize, Deserialize, Debug)]
18#[serde(rename_all = "camelCase")]
19pub struct CheckPayload {
20    pub id: String,
21    pub created: usize,
22    pub long_poll: bool,
23    pub call_i_d: String,
24    pub api_key: String
25}
26
27#[derive(Serialize, Deserialize, Debug)]
28#[serde(rename_all = "camelCase")]
29pub struct BananaResponse {
30    pub id: String,
31    pub message: String,
32    pub created: usize,
33    pub api_version: String,
34    pub call_i_d: Option<String>,
35    pub finished: Option<bool>,
36    pub model_outputs: Option<serde_json::Value>,
37}
38
39#[derive(Error, Debug)]
40pub enum BananaError {
41    #[error("error in parsing json")]
42    JsonError(reqwest::Error),
43
44    #[error("server did not return 200")]
45    ServerError(String),
46
47    #[error("Connection to server could not be established")]
48    ConnectionError(reqwest::Error),
49
50    #[error("Error in message from server")]
51    ModelError(String),
52
53    #[error("Error in response from Banana server")]
54    ResponseError(String),
55
56    #[error("Faild to get system time")]
57    TimeError(SystemTimeError)
58}