diff --git a/api_design_notes b/api_design_notes new file mode 100644 index 0000000..d8af7b9 --- /dev/null +++ b/api_design_notes @@ -0,0 +1,65 @@ +Higher level functions: + +```rust +let mut sbot_client = Sbot::connect(); + +// second parameter is `Option`; if `None`, return our relationship with `id` +// if second parameter is `Some(dest_id)`, return id's relationship with dest_id +match sbot_client.get_relationship(id, None) { + Relationship::Following => , + Relationship::NotFollowing => , + Relationship::Blocking => , + Relationship::Muting => , +} + +sbot_client.set_relationship(id, +``` + +data structures + +```rust +enum Relationship { + Following, + NotFollowing, + Blocking, + Muting +} + +struct Profile { + id: String, + name: String, + description: String, + // blob reference (maybe?) + image: String, +} +``` + +----- + +whoami - id: String + +name(id) -> name: String +description(id) -> description: String + +publish_description(id, text) -> msg_ref: String +publish_name(id, text) -> msg_ref: String +publish_post(text) -> msg_ref: String + +follows(id) -> Vec +followers(id) -> Vec +friends(id) -> Vec +blocks(id) -> Vec + +follow(id) -> msg_ref +unfollow(id) -> msg_ref +block(id) -> msg_ref + +profile_image(id) + +----- + +``` +let mut sbot_client = Sbot::init(); +``` + +----- \ No newline at end of file diff --git a/examples/ssb-client.rs b/examples/ssb-client.rs index 5a02f16..d7ae0b4 100644 --- a/examples/ssb-client.rs +++ b/examples/ssb-client.rs @@ -3,7 +3,7 @@ use std::process; use golgi::{messages::SsbMessageContent, GolgiError, Sbot}; async fn run() -> Result<(), GolgiError> { - let mut sbot_client = Sbot::connect(None, None).await?; + let mut sbot_client = Sbot::init(None, None).await?; let id = sbot_client.whoami().await?; println!("whoami: {}", id); @@ -31,7 +31,7 @@ async fn run() -> Result<(), GolgiError> { println!("post_msg_ref: {}", post_msg_ref); let post_msg_ref = sbot_client - .publish_description("this is a description7") + .publish_description("this is a description") .await?; println!("description: {}", post_msg_ref); diff --git a/examples/ssb-friends.rs b/examples/ssb-friends.rs index 8a1fceb..137d2d2 100644 --- a/examples/ssb-friends.rs +++ b/examples/ssb-friends.rs @@ -6,7 +6,7 @@ use golgi::{ }; async fn run() -> Result<(), GolgiError> { - let mut sbot_client = Sbot::connect(None, None).await?; + let mut sbot_client = Sbot::init(None, None).await?; let id = sbot_client.whoami().await?; println!("whoami: {}", id); diff --git a/examples/ssb-invite.rs b/examples/ssb-invite.rs index 42b054c..5268194 100644 --- a/examples/ssb-invite.rs +++ b/examples/ssb-invite.rs @@ -5,7 +5,7 @@ use kuska_ssb::api::dto::content::PubAddress; use golgi::{messages::SsbMessageContent, GolgiError, Sbot}; async fn run() -> Result<(), GolgiError> { - let mut sbot_client = Sbot::connect(None, None).await?; + let mut sbot_client = Sbot::init(None, None).await?; let id = sbot_client.whoami().await?; println!("whoami: {}", id); diff --git a/examples/ssb-stream-example.rs b/examples/ssb-stream-example.rs index fd1b4c2..f896e4d 100644 --- a/examples/ssb-stream-example.rs +++ b/examples/ssb-stream-example.rs @@ -9,7 +9,7 @@ use golgi::{ }; async fn run() -> Result<(), GolgiError> { - let mut sbot_client = Sbot::connect(None, None).await?; + let mut sbot_client = Sbot::init(None, None).await?; let id = sbot_client.whoami().await?; println!("whoami: {}", id); diff --git a/muxrpc_notes b/muxrpc_notes new file mode 100644 index 0000000..7218136 --- /dev/null +++ b/muxrpc_notes @@ -0,0 +1,33 @@ + + +[ how to use subset query ] + +name of the muxrpc call: `paritalReplication.getSubset` + +https://github.com/cryptoscope/ssb/blob/a781ad4ee51523df1d3858d9859c285d0eeb2fb1/sbot/manifest.go#L75-L76 + +subset query tests + +https://github.com/cryptoscope/ssb/blob/a781ad4ee51523df1d3858d9859c285d0eeb2fb1/query/subsetquery_test.go + +[ subset query args ] + +get all msgs of type `foo`: + +{"op":"type","string":"foo"} + +get all msgs by author `feed`: + +{"op":"author","feed":"@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.ed25519"} + +get all msgs of type `foo` by author `feed`: + +{"op":"and","args":[{"op":"author","feed":"@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.ed25519"},{"op":"type","string":"foo"}]} + +get all msgs of type `foo` or `bar`: + +{"op":"or","args":[{"op":"type","string":"foo"},{"op":"type","string":"bar"}]} + +get all msgs of type `foo` and `bar` by author `feed`: + +{"op":"and","args":[{"op":"author","feed":"@AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=.ed25519"},{"op":"or","args":[{"op":"type","string":"foo"},{"op":"type","string":"bar"}]}]} diff --git a/notes b/notes new file mode 100644 index 0000000..5dc3752 --- /dev/null +++ b/notes @@ -0,0 +1,34 @@ + +[ current ] + +src +├── error.rs +├── lib.rs +├── messages.rs +├── sbot +│ ├── about.rs +│ ├── friends.rs +│ ├── get_subset.rs +│ ├── history_stream.rs +│ ├── invite.rs +│ ├── mod.rs +│ ├── publish.rs +│ └── sbot_connection.rs +└── utils.rs + +[ experiment ] + +src +├── api +│ ├── about.rs +│ ├── friends.rs +│ ├── get_subset.rs +│ ├── history_stream.rs +│ ├── invite.rs +│ ├── mod.rs +│ └── publish.rs +├── error.rs +├── lib.rs +├── messages.rs +├── sbot.rs +└── utils.rs diff --git a/src/lib.rs b/src/lib.rs index 05bc007..84321e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,7 +41,7 @@ //! pub async fn run() -> Result<(), GolgiError> { //! // Attempt to connect to an sbot instance using the default IP address, //! // port and network key (aka. capabilities key). -//! let mut sbot_client = Sbot::connect(None, None).await?; +//! let mut sbot_client = Sbot::init(None, None).await?; //! //! // Call the `whoami` RPC method to retrieve the public key for the sbot //! // identity. diff --git a/src/sbot.rs b/src/sbot.rs index 33a27d6..40b958d 100644 --- a/src/sbot.rs +++ b/src/sbot.rs @@ -17,7 +17,7 @@ use crate::error::GolgiError; /// and read the responses. /// Note there can be multiple SbotConnection at the same time. pub struct SbotConnection { - /// client for writing requests to go-bot + /// Client for writing requests to go-bot pub client: ApiCaller, /// RpcReader object for reading responses from go-sbot pub rpc_reader: RpcReader, @@ -93,7 +93,7 @@ impl Sbot { .await .map_err(|source| GolgiError::Io { source, - context: "socket error; failed to initiate tcp stream connection".to_string(), + context: "failed to initiate tcp stream connection".to_string(), })?; let handshake = kuska_handshake::async_std::handshake_client(