Skip to content

Commit

Permalink
add Docs section to README.md file & add an example to p2p crate
Browse files Browse the repository at this point in the history
  • Loading branch information
hozan23 committed Nov 22, 2023
1 parent 34b0a91 commit d4c8251
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"p2p",
"jsonrpc",
]

resolver = "2"

[workspace.package]
Expand All @@ -17,3 +16,4 @@ karyons_core = { path = "core" }
karyons_net = { path = "net" }
karyons_p2p = { path = "p2p" }
karyons_jsonrpc = { path = "jsonrpc" }

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Join us on:
along with common network functionality.
- [karyons p2p](./p2p): A lightweight, extensible, and customizable
peer-to-peer (p2p) network stack.
- [karyons jsonrpc](./jsonrpc): A fast and lightweight async
- [karyons jsonrpc](./jsonrpc): A fast and small async
[JSONRPC2.0](https://www.jsonrpc.org/specification) implementation.
- karyons crdt: A [CRDT](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type)
implementation for building collaborative software.
Expand All @@ -29,6 +29,14 @@ crdt and karyons store, along with major changes to the network stack,
including TLS implementation. You can check the
[issues](https://github.com/karyons/karyons/issues) for updates on ongoing tasks.

## Docs

To generate karyons Rust API Documentation, run the following command:

```bash
$ cargo doc --no-deps --all --document-private-items --open
```

## Thanks

Big thanks to [Ink & Switch](https://www.inkandswitch.com/) team,
Expand Down
34 changes: 0 additions & 34 deletions p2p/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,6 @@ pub type ArcBackend = Arc<Backend>;
/// the P2P network.
///
///
/// # Example
/// ```
/// use std::sync::Arc;
///
/// use easy_parallel::Parallel;
/// use smol::{channel as smol_channel, future, Executor};
///
/// use karyons_p2p::{Backend, Config, PeerID};
///
/// let peer_id = PeerID::random();
///
/// // Create the configuration for the backend.
/// let mut config = Config::default();
///
///
/// // Create a new Executor
/// let ex = Arc::new(Executor::new());
///
/// // Create a new Backend
/// let backend = Backend::new(peer_id, config, ex.clone());
///
/// let task = async {
/// // Run the backend
/// backend.run().await.unwrap();
///
/// // ....
///
/// // Shutdown the backend
/// backend.shutdown().await;
/// };
///
/// future::block_on(ex.run(task));
///
/// ```
pub struct Backend {
/// The Configuration for the P2P network.
config: Arc<Config>,
Expand Down
37 changes: 37 additions & 0 deletions p2p/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
//! A lightweight, extensible, and customizable peer-to-peer (p2p) network stack.
//!
//! # Example
//! ```
//! use std::sync::Arc;
//!
//! use easy_parallel::Parallel;
//! use smol::{channel as smol_channel, future, Executor};
//!
//! use karyons_p2p::{Backend, Config, PeerID};
//!
//! let peer_id = PeerID::random();
//!
//! // Create the configuration for the backend.
//! let mut config = Config::default();
//!
//!
//! // Create a new Executor
//! let ex = Arc::new(Executor::new());
//!
//! // Create a new Backend
//! let backend = Backend::new(peer_id, config, ex.clone());
//!
//! let task = async {
//! // Run the backend
//! backend.run().await.unwrap();
//!
//! // ....
//!
//! // Shutdown the backend
//! backend.shutdown().await;
//! };
//!
//! future::block_on(ex.run(task));
//!
//! ```
//!
mod backend;
mod config;
mod connection;
Expand Down

0 comments on commit d4c8251

Please sign in to comment.