pass CreateHistoryStream as arg

This commit is contained in:
glyph 2022-08-09 08:24:39 +01:00
parent e16f567c19
commit 80e99deb6f
1 changed files with 10 additions and 5 deletions

View File

@ -5,7 +5,7 @@
//! - [`Sbot::create_history_stream`]
use async_std::stream::Stream;
use kuska_ssb::api::dto::CreateHistoryStreamIn;
pub use kuska_ssb::api::dto::CreateHistoryStreamIn as CreateHistoryStream;
use crate::{error::GolgiError, messages::SsbMessageKVT, sbot::Sbot, utils};
@ -17,14 +17,20 @@ impl Sbot {
///
/// ```rust
/// use async_std::stream::StreamExt;
/// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// use golgi::{
/// Sbot,
/// GolgiError,
/// sbot::Keystore,
/// api::history_stream::CreateHistoryStream
/// };
///
/// async fn history() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519".to_string();
///
/// let history_stream = sbot_client.create_history_stream(ssb_id).await?;
/// let args = CreateHistoryStream::new(ssb_id);
/// let history_stream = sbot_client.create_history_stream(args).await?;
///
/// history_stream.for_each(|msg| {
/// match msg {
@ -38,10 +44,9 @@ impl Sbot {
/// ```
pub async fn create_history_stream(
&mut self,
id: String,
args: CreateHistoryStream,
) -> Result<impl Stream<Item = Result<SsbMessageKVT, GolgiError>>, GolgiError> {
let mut sbot_connection = self.get_sbot_connection().await?;
let args = CreateHistoryStreamIn::new(id).keys_values(true, true);
let req_id = sbot_connection
.client
.create_history_stream_req_send(&args)