async_llm/http/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use futures::Stream;
use serde::{de::DeserializeOwned, Serialize};
use std::{fmt::Debug, pin::Pin};

use crate::error::Error;

pub mod simple;
pub mod stream;
pub use simple::SimpleHttpClient;

#[async_trait::async_trait]
pub trait HttpClient: Debug + Clone + Send + Sync {
    async fn post<I: Serialize + Send, O: DeserializeOwned>(
        &self,
        path: &str,
        request: I,
    ) -> Result<O, Error>;
    async fn post_stream<I: Serialize + Send, O: DeserializeOwned + Send + 'static>(
        &self,
        path: &str,
        request: I,
    ) -> Result<Pin<Box<dyn Stream<Item = Result<O, Error>> + Send>>, Error>;
}