diff --git a/autonomi/README_WASM.md b/autonomi/README_WASM.md index cf9a2c6d8f..8c6478def7 100644 --- a/autonomi/README_WASM.md +++ b/autonomi/README_WASM.md @@ -55,7 +55,7 @@ To run a WASM test Example: ```sh -ANT_PEERS=/ip4//tcp//ws/p2p/ wasm-pack test --release --firefox autonomi --features=data,files --test wasm -- put +ANT_PEERS=/ip4//tcp//ws/p2p/ wasm-pack test --release --firefox autonomi --features=files --test wasm -- put ``` ### Test from JS in the browser diff --git a/autonomi/src/client/fs.rs b/autonomi/src/client/fs.rs index 15e32d1bf5..2dced2beee 100644 --- a/autonomi/src/client/fs.rs +++ b/autonomi/src/client/fs.rs @@ -36,7 +36,6 @@ pub static FILE_UPLOAD_BATCH_SIZE: LazyLock = LazyLock::new(|| { }); /// Errors that can occur during the file upload operation. -#[cfg(feature = "fs")] #[derive(Debug, thiserror::Error)] pub enum UploadError { #[error("Failed to recursively traverse directory")] @@ -53,7 +52,6 @@ pub enum UploadError { Deserialization(#[from] rmp_serde::decode::Error), } -#[cfg(feature = "fs")] /// Errors that can occur during the download operation. #[derive(Debug, thiserror::Error)] pub enum DownloadError { @@ -63,7 +61,6 @@ pub enum DownloadError { IoError(#[from] std::io::Error), } -#[cfg(feature = "fs")] /// Errors that can occur during the file cost calculation. #[derive(Debug, thiserror::Error)] pub enum FileCostError { diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index f93fba1157..be0579c29d 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -6,6 +6,9 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. +// Optionally enable nightly `doc_cfg`. Allows items to be annotated, e.g.: "Available on crate feature X only". +#![cfg_attr(docsrs, feature(doc_cfg))] + pub mod address; pub mod payment; @@ -14,14 +17,19 @@ pub mod archive_private; pub mod data; pub mod data_private; #[cfg(feature = "external-signer")] +#[cfg_attr(docsrs, doc(cfg(feature = "external-signer")))] pub mod external_signer; #[cfg(feature = "fs")] +#[cfg_attr(docsrs, doc(cfg(feature = "fs")))] pub mod fs; #[cfg(feature = "fs")] +#[cfg_attr(docsrs, doc(cfg(feature = "fs")))] pub mod fs_private; #[cfg(feature = "registers")] +#[cfg_attr(docsrs, doc(cfg(feature = "registers")))] pub mod registers; #[cfg(feature = "vault")] +#[cfg_attr(docsrs, doc(cfg(feature = "vault")))] pub mod vault; #[cfg(target_arch = "wasm32")] diff --git a/autonomi/src/lib.rs b/autonomi/src/lib.rs index 9e288cd05e..4f219ea116 100644 --- a/autonomi/src/lib.rs +++ b/autonomi/src/lib.rs @@ -8,6 +8,31 @@ //! Connect to and build on the Autonomi network. //! +//! # Example +//! +//! ```rust +//! use autonomi::{Bytes, Client, Wallet}; +//! +//! #[tokio::main] +//! async fn main() -> Result<(), Box> { +//! let client = Client::connect(&["/ip4/127.0.0.1/udp/1234/quic-v1".parse()?]).await?; +//! +//! // Default wallet of testnet. +//! let key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"; +//! let wallet = Wallet::new_from_private_key(Default::default(), key)?; +//! +//! // Put and fetch data. +//! let data_addr = client.data_put(Bytes::from("Hello, World"), (&wallet).into()).await?; +//! let _data_fetched = client.data_get(data_addr).await?; +//! +//! // Put and fetch directory from local file system. +//! let dir_addr = client.dir_upload("files/to/upload".into(), &wallet).await?; +//! client.dir_download(dir_addr, "files/downloaded".into()).await?; +//! +//! Ok(()) +//! } +//! ``` +//! //! # Data types //! //! This API gives access to two fundamental types on the network: chunks and