* use reqwest

* support multipart form
* fix audio apits
This commit is contained in:
Dongri Jin
2024-07-09 18:47:51 +09:00
parent be660448f4
commit 3e5286dad6
18 changed files with 489 additions and 675 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
use std::collections::HashMap;
use reqwest::header::HeaderMap;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::impl_builder_methods;
@@ -115,8 +115,8 @@ impl AudioSpeechRequest {
impl_builder_methods!(AudioSpeechRequest,);
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug)]
pub struct AudioSpeechResponse {
pub result: bool,
pub headers: Option<HashMap<String, String>>,
pub headers: Option<HeaderMap>,
}

View File

@@ -1,15 +1,26 @@
use reqwest::{self};
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub struct APIError {
pub message: String,
pub enum APIError {
ReqwestError(reqwest::Error),
CustomError { message: String },
}
impl fmt::Display for APIError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "APIError: {}", self.message)
match self {
APIError::ReqwestError(err) => write!(f, "ReqwestError: {}", err),
APIError::CustomError { message } => write!(f, "APIError: {}", message),
}
}
}
impl Error for APIError {}
impl From<reqwest::Error> for APIError {
fn from(err: reqwest::Error) -> APIError {
APIError::ReqwestError(err)
}
}