update docs and doc example code to use new keystore selector

This commit is contained in:
glyph 2022-05-11 14:14:25 +02:00
parent d6546733aa
commit 9cb8b62843
14 changed files with 98 additions and 90 deletions

View File

@ -12,8 +12,6 @@ Golgi is an asynchronous, experimental Scuttlebutt client that aims to
facilitate Scuttlebutt application development. It provides a high-level facilitate Scuttlebutt application development. It provides a high-level
API for interacting with an sbot instance and uses the API for interacting with an sbot instance and uses the
[kuska-ssb](https://github.com/Kuska-ssb) libraries to make RPC calls. [kuska-ssb](https://github.com/Kuska-ssb) libraries to make RPC calls.
Development efforts are currently oriented towards
[go-sbot](https://github.com/cryptoscope/ssb) interoperability.
## Features ## Features
@ -33,12 +31,13 @@ Basic usage is demonstrated below. Visit the [examples directory](https://git.co
more comprehensive examples. more comprehensive examples.
```rust ```rust
use golgi::{GolgiError, Sbot}; use golgi::{GolgiError, Sbot, sbot::Keystore};
pub async fn run() -> Result<(), GolgiError> { pub async fn run() -> Result<(), GolgiError> {
// Attempt to initialise a connection to an sbot instance using the default // Attempt to initialise a connection to an sbot instance using the
// IP address, port and network key (aka. capabilities key). // secret file at the Patchwork path and the default IP address, port
let mut sbot_client = Sbot::init(None, None).await?; // and network key (aka. capabilities key).
let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
// Call the `whoami` RPC method to retrieve the public key for the sbot // Call the `whoami` RPC method to retrieve the public key for the sbot
// identity. // identity.

View File

@ -1,14 +1,15 @@
use std::process; use std::process;
use golgi::{messages::SsbMessageContent, GolgiError, Sbot}; use golgi::{messages::SsbMessageContent, sbot::Keystore, GolgiError, Sbot};
// Golgi is an asynchronous library so we must call it from within an // Golgi is an asynchronous library so we must call it from within an
// async function. The `GolgiError` type encapsulates all possible // async function. The `GolgiError` type encapsulates all possible
// error variants for the library. // error variants for the library.
async fn run() -> Result<(), GolgiError> { async fn run() -> Result<(), GolgiError> {
// Attempt to connect to an sbot instance using the default IP address, // Attempt to initialise a connection to an sbot instance using the
// port and network key (aka. capabilities key). // secret file at the Patchwork path and the default IP address, port
let mut sbot_client = Sbot::init(None, None).await?; // and network key (aka. capabilities key).
let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
// Alternatively, we could specify a non-standard IP and port. // Alternatively, we could specify a non-standard IP and port.
// let ip_port = "127.0.0.1:8021".to_string(); // let ip_port = "127.0.0.1:8021".to_string();

View File

@ -2,6 +2,7 @@ use std::process;
use golgi::{ use golgi::{
api::friends::{FriendsHops, RelationshipQuery}, api::friends::{FriendsHops, RelationshipQuery},
sbot::Keystore,
GolgiError, Sbot, GolgiError, Sbot,
}; };
@ -9,9 +10,10 @@ use golgi::{
// async function. The `GolgiError` type encapsulates all possible // async function. The `GolgiError` type encapsulates all possible
// error variants for the library. // error variants for the library.
async fn run() -> Result<(), GolgiError> { async fn run() -> Result<(), GolgiError> {
// Attempt to connect to an sbot instance using the default IP address, // Attempt to initialise a connection to an sbot instance using the
// port and network key (aka. capabilities key). // secret file at the Patchwork path and the default IP address, port
let mut sbot_client = Sbot::init(None, None).await?; // and network key (aka. capabilities key).
let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
// Call the `whoami` RPC method to retrieve the public key for the sbot // Call the `whoami` RPC method to retrieve the public key for the sbot
// identity. This is our 'local' public key. // identity. This is our 'local' public key.
@ -26,10 +28,10 @@ async fn run() -> Result<(), GolgiError> {
// Set the relationship of the local identity to the `to_follow` identity. // Set the relationship of the local identity to the `to_follow` identity.
// In this case, the `set_relationship` method publishes a `contact` // In this case, the `set_relationship` method publishes a `contact`
// message which defines following as `true` and blocking as `false`. // message which defines following as `true`.
// A message reference is returned for the published `contact` message. // A message reference is returned for the published `contact` message.
let response = sbot_client let response = sbot_client
.set_relationship(&to_follow, true, false) .set_relationship(&to_follow, Some(true), None)
.await?; .await?;
// Print the message reference to `stdout`. // Print the message reference to `stdout`.
@ -37,9 +39,11 @@ async fn run() -> Result<(), GolgiError> {
// Set the relationship of the local identity to the `to_block` identity. // Set the relationship of the local identity to the `to_block` identity.
// In this case, the `set_relationship` method publishes a `contact` // In this case, the `set_relationship` method publishes a `contact`
// message which defines following as `false` and blocking as `true`. // message which defines blocking as `true`.
// A message reference is returned for the published `contact` message. // A message reference is returned for the published `contact` message.
let response = sbot_client.set_relationship(&to_block, false, true).await?; let response = sbot_client
.set_relationship(&to_block, None, Some(true))
.await?;
// Print the message reference to `stdout`. // Print the message reference to `stdout`.
println!("follow_response: {:?}", response); println!("follow_response: {:?}", response);

View File

@ -2,15 +2,16 @@ use std::process;
use kuska_ssb::api::dto::content::PubAddress; use kuska_ssb::api::dto::content::PubAddress;
use golgi::{messages::SsbMessageContent, GolgiError, Sbot}; use golgi::{messages::SsbMessageContent, sbot::Keystore, GolgiError, Sbot};
// Golgi is an asynchronous library so we must call it from within an // Golgi is an asynchronous library so we must call it from within an
// async function. The `GolgiError` type encapsulates all possible // async function. The `GolgiError` type encapsulates all possible
// error variants for the library. // error variants for the library.
async fn run() -> Result<(), GolgiError> { async fn run() -> Result<(), GolgiError> {
// Attempt to connect to an sbot instance using the default IP address, // Attempt to initialise a connection to an sbot instance using the
// port and network key (aka. capabilities key). // secret file at the Patchwork path and the default IP address, port
let mut sbot_client = Sbot::init(None, None).await?; // and network key (aka. capabilities key).
let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
// Call the `whoami` RPC method to retrieve the public key for the sbot // Call the `whoami` RPC method to retrieve the public key for the sbot
// identity. This is our 'local' public key. // identity. This is our 'local' public key.

View File

@ -6,6 +6,7 @@ use futures::TryStreamExt;
use golgi::{ use golgi::{
api::get_subset::{SubsetQuery, SubsetQueryOptions}, api::get_subset::{SubsetQuery, SubsetQueryOptions},
messages::{SsbMessageContentType, SsbMessageValue}, messages::{SsbMessageContentType, SsbMessageValue},
sbot::Keystore,
GolgiError, Sbot, GolgiError, Sbot,
}; };
@ -13,9 +14,10 @@ use golgi::{
// async function. The `GolgiError` type encapsulates all possible // async function. The `GolgiError` type encapsulates all possible
// error variants for the library. // error variants for the library.
async fn run() -> Result<(), GolgiError> { async fn run() -> Result<(), GolgiError> {
// Attempt to connect to an sbot instance using the default IP address, // Attempt to initialise a connection to an sbot instance using the
// port and network key (aka. capabilities key). // secret file at the Patchwork path and the default IP address, port
let mut sbot_client = Sbot::init(None, None).await?; // and network key (aka. capabilities key).
let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
// Call the `whoami` RPC method to retrieve the public key for the sbot // Call the `whoami` RPC method to retrieve the public key for the sbot
// identity. This is our 'local' public key. // identity. This is our 'local' public key.

View File

@ -29,10 +29,10 @@ impl Sbot {
/// ///
/// ```rust /// ```rust
/// use async_std::stream::{Stream, StreamExt}; /// use async_std::stream::{Stream, StreamExt};
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn about_message_stream() -> Result<(), GolgiError> { /// async fn about_message_stream() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -88,10 +88,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn name_info() -> Result<(), GolgiError> { /// async fn name_info() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// let key = "name"; /// let key = "name";
@ -154,10 +154,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn profile_info() -> Result<(), GolgiError> { /// async fn profile_info() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -196,10 +196,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn name_and_image_info() -> Result<(), GolgiError> { /// async fn name_and_image_info() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -243,10 +243,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn about_info() -> Result<(), GolgiError> { /// async fn about_info() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// let keys_to_search_for = vec!["name", "description"]; /// let keys_to_search_for = vec!["name", "description"];
@ -340,10 +340,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn name_info() -> Result<(), GolgiError> { /// async fn name_info() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -365,10 +365,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn description_info() -> Result<(), GolgiError> { /// async fn description_info() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///

View File

@ -27,10 +27,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn follow_peer() -> Result<(), GolgiError> { /// async fn follow_peer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -56,10 +56,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn unfollow_peer() -> Result<(), GolgiError> { /// async fn unfollow_peer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -85,10 +85,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn block_peer() -> Result<(), GolgiError> { /// async fn block_peer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -116,10 +116,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn unblock_peer() -> Result<(), GolgiError> { /// async fn unblock_peer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// ///
@ -142,10 +142,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn relationship() -> Result<(), GolgiError> { /// async fn relationship() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// let following = Some(true); /// let following = Some(true);
@ -184,10 +184,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError, api::friends::RelationshipQuery}; /// use golgi::{Sbot, GolgiError, api::friends::RelationshipQuery, sbot::Keystore};
/// ///
/// async fn relationship() -> Result<(), GolgiError> { /// async fn relationship() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let peer_a = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let peer_a = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// let peer_b = "@3QoWCcy46X9a4jTnOl8m3+n1gKfbsukWuODDxNGN0W8=.ed25519"; /// let peer_b = "@3QoWCcy46X9a4jTnOl8m3+n1gKfbsukWuODDxNGN0W8=.ed25519";
@ -234,10 +234,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError, api::friends::RelationshipQuery}; /// use golgi::{Sbot, GolgiError, api::friends::RelationshipQuery, sbot::Keystore};
/// ///
/// async fn relationship() -> Result<(), GolgiError> { /// async fn relationship() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let peer_a = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519"; /// let peer_a = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519";
/// let peer_b = "@3QoWCcy46X9a4jTnOl8m3+n1gKfbsukWuODDxNGN0W8=.ed25519"; /// let peer_b = "@3QoWCcy46X9a4jTnOl8m3+n1gKfbsukWuODDxNGN0W8=.ed25519";
@ -282,10 +282,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn follows() -> Result<(), GolgiError> { /// async fn follows() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let follows = sbot_client.get_blocks().await?; /// let follows = sbot_client.get_blocks().await?;
/// ///
@ -314,10 +314,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn follows() -> Result<(), GolgiError> { /// async fn follows() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let follows = sbot_client.get_follows().await?; /// let follows = sbot_client.get_follows().await?;
/// ///
@ -350,10 +350,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn followers() -> Result<(), GolgiError> { /// async fn followers() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// // let followers = sbot_client.get_followers().await?; /// // let followers = sbot_client.get_followers().await?;
/// ///
@ -395,10 +395,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError, api::friends::FriendsHops}; /// use golgi::{Sbot, GolgiError, api::friends::FriendsHops, sbot::Keystore};
/// ///
/// async fn peers_within_range() -> Result<(), GolgiError> { /// async fn peers_within_range() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let hops = 2; /// let hops = 2;
/// ///

View File

@ -33,11 +33,12 @@ impl Sbot {
/// api::get_subset::{ /// api::get_subset::{
/// SubsetQuery, /// SubsetQuery,
/// SubsetQueryOptions /// SubsetQueryOptions
/// } /// },
/// sbot::Keystore
/// }; /// };
/// ///
/// async fn query() -> Result<(), GolgiError> { /// async fn query() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let post_query = SubsetQuery::Type { /// let post_query = SubsetQuery::Type {
/// op: "type".to_string(), /// op: "type".to_string(),

View File

@ -16,10 +16,10 @@ impl Sbot {
/// ///
/// ```rust /// ```rust
/// use async_std::stream::StreamExt; /// use async_std::stream::StreamExt;
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn history() -> Result<(), GolgiError> { /// async fn history() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519".to_string(); /// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519".to_string();
/// ///

View File

@ -15,10 +15,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn invite_code_generator() -> Result<(), GolgiError> { /// async fn invite_code_generator() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let invite_code = sbot_client.invite_create(5).await?; /// let invite_code = sbot_client.invite_create(5).await?;
/// ///
@ -47,10 +47,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn invite_code_consumer() -> Result<(), GolgiError> { /// async fn invite_code_consumer() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let invite_code = "127.0.0.1:8008:@0iMa+vP7B2aMrV3dzRxlch/iqZn/UM3S3Oo2oVeILY8=.ed25519~ZHNjeajPB/84NjjsrglZInlh46W55RcNDPcffTPgX/Q="; /// let invite_code = "127.0.0.1:8008:@0iMa+vP7B2aMrV3dzRxlch/iqZn/UM3S3Oo2oVeILY8=.ed25519~ZHNjeajPB/84NjjsrglZInlh46W55RcNDPcffTPgX/Q=";
/// ///

View File

@ -17,21 +17,21 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError, messages::SsbMessageContent}; /// use golgi::{Sbot, GolgiError, messages::SsbMessageContent, sbot::Keystore};
/// ///
/// async fn publish_a_private_msg() -> Result<(), GolgiError> { /// async fn publish_a_private_msg() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let text = String::new("Hi friends, I have a super secrect message to share with you about the wonders of intra-cellular transport mechanics."); /// let text = String::from("Hi friends, I have a super secrect message to share with you about the wonders of intra-cellular transport mechanics.");
/// ///
/// // We must also include the local identity (public key) here if we wish /// // We must also include the local identity (public key) here if we wish
/// // to be able to read the message. Ie. the sender must be included in /// // to be able to read the message. Ie. the sender must be included in
/// // the list of recipients. /// // the list of recipients.
/// let recipients = Vec::new( /// let recipients = vec![
/// String::new("@OKRij/n7Uu42A0Z75ty0JI0cZxcieD2NyjXrRdYKNOQ=.ed25519"), /// String::from("@OKRij/n7Uu42A0Z75ty0JI0cZxcieD2NyjXrRdYKNOQ=.ed25519"),
/// String::new("@Sih4JGgs5oQPXehRyHS5qrYbx/0hQVUqChojX0LNtcQ=.ed25519"), /// String::from("@Sih4JGgs5oQPXehRyHS5qrYbx/0hQVUqChojX0LNtcQ=.ed25519"),
/// String::new("@BVA85B7a/a17v2ZVcLkMgPE+v7X5rQVAHEgQBbCaKMs=.ed25519"), /// String::from("@BVA85B7a/a17v2ZVcLkMgPE+v7X5rQVAHEgQBbCaKMs=.ed25519"),
/// ); /// ];
/// ///
/// let msg_ref = sbot_client.publish_private(text, recipients).await?; /// let msg_ref = sbot_client.publish_private(text, recipients).await?;
/// ///

View File

@ -23,10 +23,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError, messages::SsbMessageContent}; /// use golgi::{Sbot, GolgiError, messages::SsbMessageContent, sbot::Keystore};
/// ///
/// async fn publish_a_msg() -> Result<(), GolgiError> { /// async fn publish_a_msg() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// // Construct an SSB message of type `post`. /// // Construct an SSB message of type `post`.
/// let post = SsbMessageContent::Post { /// let post = SsbMessageContent::Post {
@ -61,10 +61,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn publish_a_post() -> Result<(), GolgiError> { /// async fn publish_a_post() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let text = "The Golgi is located right near the nucleus."; /// let text = "The Golgi is located right near the nucleus.";
/// ///
@ -91,10 +91,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn publish_a_description() -> Result<(), GolgiError> { /// async fn publish_a_description() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let description = "The Golgi apparatus was identified by the Italian scientist Camillo Golgi in 1897."; /// let description = "The Golgi apparatus was identified by the Italian scientist Camillo Golgi in 1897.";
/// ///
@ -130,10 +130,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn publish_an_image() -> Result<(), GolgiError> { /// async fn publish_an_image() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let blob_id = "&JlJHc9yeG1EpZA9fIPGLzUKDH0FeR39Ai57euhKT1G8=.sha256"; /// let blob_id = "&JlJHc9yeG1EpZA9fIPGLzUKDH0FeR39Ai57euhKT1G8=.sha256";
/// ///
@ -166,10 +166,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn publish_a_name() -> Result<(), GolgiError> { /// async fn publish_a_name() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let name = "glyphski_golgionikus"; /// let name = "glyphski_golgionikus";
/// ///

View File

@ -12,10 +12,10 @@ impl Sbot {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use golgi::{Sbot, GolgiError}; /// use golgi::{Sbot, GolgiError, sbot::Keystore};
/// ///
/// async fn fetch_id() -> Result<(), GolgiError> { /// async fn fetch_id() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?; /// let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
/// ///
/// let pub_key = sbot_client.whoami().await?; /// let pub_key = sbot_client.whoami().await?;
/// ///

View File

@ -38,12 +38,12 @@
//! more comprehensive examples. //! more comprehensive examples.
//! //!
//! ```rust //! ```rust
//! use golgi::{messages::SsbMessageContent, GolgiError, Sbot}; //! use golgi::{messages::SsbMessageContent, GolgiError, Sbot, sbot::Keystore};
//! //!
//! pub async fn run() -> Result<(), GolgiError> { //! pub async fn run() -> Result<(), GolgiError> {
//! // Attempt to connect to an sbot instance using the default IP address, //! // Attempt to connect to an sbot instance using the default IP address,
//! // port and network key (aka. capabilities key). //! // port and network key (aka. capabilities key).
//! let mut sbot_client = Sbot::init(None, None).await?; //! let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
//! //!
//! // Call the `whoami` RPC method to retrieve the public key for the sbot //! // Call the `whoami` RPC method to retrieve the public key for the sbot
//! // identity. //! // identity.