From 80e99deb6fff3cc417e1bec0c8ae74f2e5a7b84d Mon Sep 17 00:00:00 2001 From: glyph Date: Tue, 9 Aug 2022 08:24:39 +0100 Subject: [PATCH 1/3] pass CreateHistoryStream as arg --- src/api/history_stream.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/api/history_stream.rs b/src/api/history_stream.rs index 0cfbe8f..2154773 100644 --- a/src/api/history_stream.rs +++ b/src/api/history_stream.rs @@ -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>, 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) From c556373a9691182ab8f01c28babe81a1e98da9f1 Mon Sep 17 00:00:00 2001 From: glyph Date: Tue, 9 Aug 2022 08:24:53 +0100 Subject: [PATCH 2/3] update create_history_stream example --- examples/streams.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/streams.rs b/examples/streams.rs index a9b9106..be7d5bc 100644 --- a/examples/streams.rs +++ b/examples/streams.rs @@ -4,7 +4,10 @@ use async_std::stream::StreamExt; use futures::TryStreamExt; use golgi::{ - api::get_subset::{SubsetQuery, SubsetQueryOptions}, + api::{ + get_subset::{SubsetQuery, SubsetQueryOptions}, + history_stream::CreateHistoryStream, + }, messages::{SsbMessageContentType, SsbMessageKVT}, sbot::Keystore, GolgiError, Sbot, @@ -30,10 +33,11 @@ async fn run() -> Result<(), GolgiError> { /* HISTORY STREAM EXAMPLE */ + let history_stream_args = CreateHistoryStream::new(author.to_string()); // Create an ordered stream of all messages authored by the `author` // identity. Messages are returned as KVTs (Key Value Timestamp). let history_stream = sbot_client - .create_history_stream(author.to_string()) + .create_history_stream(history_stream_args) .await?; // Pin the stream to the stack to allow polling of the `future`. @@ -61,7 +65,7 @@ async fn run() -> Result<(), GolgiError> { // Create an ordered stream of all messages authored by the `author` // identity. let history_stream = sbot_client - .create_history_stream(author.to_string()) + .create_history_stream(CreateHistoryStream::new(author.to_string())) .await?; // Collect the stream elements into a `Vec` using @@ -78,7 +82,7 @@ async fn run() -> Result<(), GolgiError> { // Create an ordered stream of all messages authored by the `author` // identity. let history_stream = sbot_client - .create_history_stream(author.to_string()) + .create_history_stream(CreateHistoryStream::new(author.to_string())) .await?; // Iterate through the elements in the stream and use `map` to convert From 1335aeb54415c695709e13dab750715fb31fd7e2 Mon Sep 17 00:00:00 2001 From: glyph Date: Tue, 9 Aug 2022 08:26:39 +0100 Subject: [PATCH 3/3] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index beb2bf9..1083421 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "golgi" -version = "0.2.3" +version = "0.2.4" edition = "2021" authors = ["Max Fowler ", "Andrew Reid "] readme = "README.md"