Skip to content

Commit

Permalink
docs(pubky): small docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Aug 8, 2024
1 parent 386e51e commit 21c0079
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions pubky/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use ::pkarr::PkarrClientAsync;

pub use error::Error;

#[cfg(not(target_arch = "wasm32"))]
pub use crate::shared::list_builder::ListBuilder;

#[derive(Debug, Clone)]
#[wasm_bindgen]
pub struct PubkyClient {
Expand Down
4 changes: 2 additions & 2 deletions pubky/src/shared/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl PubkyClient {
}

/// Signout from a homeserver.
pub async fn inner_signout(&self, pubky: &PublicKey) -> Result<()> {
pub(crate) async fn inner_signout(&self, pubky: &PublicKey) -> Result<()> {
let Endpoint {
public_key,
mut url,
Expand All @@ -90,7 +90,7 @@ impl PubkyClient {
}

/// Signin to a homeserver.
pub async fn inner_signin(&self, keypair: &Keypair) -> Result<()> {
pub(crate) async fn inner_signin(&self, keypair: &Keypair) -> Result<()> {
let pubky = keypair.public_key();

let Endpoint {
Expand Down
5 changes: 3 additions & 2 deletions pubky/src/shared/list_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct ListBuilder<'a> {

impl<'a> ListBuilder<'a> {
/// Create a new List request builder
pub fn new(client: &'a PubkyClient, url: Url) -> Self {
pub(crate) fn new(client: &'a PubkyClient, url: Url) -> Self {
Self {
client,
url,
Expand All @@ -40,7 +40,8 @@ impl<'a> ListBuilder<'a> {

/// Set the `cursor` value.
///
/// usually the last url from previous responses.
/// Either a full `pubky://` Url (from previous list response),
/// or a path (to a file or directory) relative to the `url`
pub fn cursor(mut self, cursor: &'a str) -> Self {
self.cursor = cursor.into();
self
Expand Down
8 changes: 4 additions & 4 deletions pubky/src/shared/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
use super::{list_builder::ListBuilder, pkarr::Endpoint};

impl PubkyClient {
pub async fn inner_put<T: TryInto<Url>>(&self, url: T, content: &[u8]) -> Result<()> {
pub(crate) async fn inner_put<T: TryInto<Url>>(&self, url: T, content: &[u8]) -> Result<()> {
let url = self.pubky_to_http(url).await?;

let response = self
Expand All @@ -26,7 +26,7 @@ impl PubkyClient {
Ok(())
}

pub async fn inner_get<T: TryInto<Url>>(&self, url: T) -> Result<Option<Bytes>> {
pub(crate) async fn inner_get<T: TryInto<Url>>(&self, url: T) -> Result<Option<Bytes>> {
let url = self.pubky_to_http(url).await?;

let response = self.request(Method::GET, url).send().await?;
Expand All @@ -43,7 +43,7 @@ impl PubkyClient {
Ok(Some(bytes))
}

pub async fn inner_delete<T: TryInto<Url>>(&self, url: T) -> Result<()> {
pub(crate) async fn inner_delete<T: TryInto<Url>>(&self, url: T) -> Result<()> {
let url = self.pubky_to_http(url).await?;

let response = self.request(Method::DELETE, url).send().await?;
Expand All @@ -53,7 +53,7 @@ impl PubkyClient {
Ok(())
}

pub fn inner_list<T: TryInto<Url>>(&self, url: T) -> Result<ListBuilder> {
pub(crate) fn inner_list<T: TryInto<Url>>(&self, url: T) -> Result<ListBuilder> {
Ok(ListBuilder::new(
self,
url.try_into().map_err(|_| Error::InvalidUrl)?,
Expand Down
10 changes: 7 additions & 3 deletions pubky/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ impl PubkyClient {
self.inner_delete(url).await.map_err(|e| e.into())
}

/// Returns a list of Pubky URLs of the files within the `url` path,
/// respecting the `cursor`, `reverse` and `limit` options.
/// Returns a list of Pubky urls (as strings).
///
/// `cursor` is usually the last url from previous responses.
/// - `url`: The Pubky url (string) to the directory you want to list its content.
/// - `cursor`: Either a full `pubky://` Url (from previous list response),
/// or a path (to a file or directory) relative to the `url`
/// - `reverse`: List in reverse order
/// - `limit` Limit the number of urls in the response
/// - `shallow`: List directories and files, instead of flat list of files.
#[wasm_bindgen]
pub async fn list(
&self,
Expand Down

0 comments on commit 21c0079

Please sign in to comment.