31 lines
969 B
Rust
31 lines
969 B
Rust
|
use async_std::stream::Stream;
|
||
|
use kuska_ssb::api::dto::CreateHistoryStreamIn;
|
||
|
|
||
|
use crate::{
|
||
|
error::GolgiError, messages::SsbMessageValue, sbot::sbot_connection::Sbot, utils,
|
||
|
utils::get_source_stream,
|
||
|
};
|
||
|
|
||
|
impl Sbot {
|
||
|
/// Call the `createHistoryStream` RPC method
|
||
|
/// and return a Stream of Result<SsbMessageValue, GolgiError>.
|
||
|
pub async fn create_history_stream(
|
||
|
&mut self,
|
||
|
id: String,
|
||
|
) -> Result<impl Stream<Item = Result<SsbMessageValue, GolgiError>>, GolgiError> {
|
||
|
let mut sbot_connection = self.get_sbot_connection().await?;
|
||
|
let args = CreateHistoryStreamIn::new(id);
|
||
|
let req_id = sbot_connection
|
||
|
.client
|
||
|
.create_history_stream_req_send(&args)
|
||
|
.await?;
|
||
|
let history_stream = get_source_stream(
|
||
|
sbot_connection.rpc_reader,
|
||
|
req_id,
|
||
|
utils::ssb_message_res_parse,
|
||
|
)
|
||
|
.await;
|
||
|
Ok(history_stream)
|
||
|
}
|
||
|
}
|