arti-client example: Try to make the comments a little more clear.

I'm not 100% sure this is better, but it might help the user
understand how Arti works a bit better.
This commit is contained in:
Nick Mathewson 2021-10-28 20:18:04 -04:00
parent 672335ccf6
commit bf3bfdf62d
1 changed files with 10 additions and 6 deletions

View File

@ -55,14 +55,16 @@
//! # use tokio_crate as tokio;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! // The client config includes things like where to store persistent Tor network state.
//! // The client configuration describes how to connect to the Tor network,
//! // and what directories to use for storing persistent state.
//! let config = TorClientConfig::sane_defaults()?;
//! // Arti needs a handle to an async runtime in order to spawn async tasks.
//! // (See "Multiple runtime support" below.)
//! // Arti needs a handle to an async runtime in order to spawn tasks and use the
//! // network. (See "Multiple runtime support" below.)
//! let rt = tor_rtcompat::tokio::current_runtime()?;
//!
//! // Start the Arti client, and let it bootstrap a connection to the Tor network.
//! // (This takes a while to gather the necessary consensus state, etc.)
//! // (This takes a while to gather the necessary directory information.
//! // It uses cached information when possible.)
//! let tor_client = TorClient::bootstrap(rt, config).await?;
//!
//! // Initiate a connection over Tor to example.com, port 80.
@ -76,8 +78,7 @@
//! .await?;
//!
//! // IMPORTANT: Make sure the request was written.
//! // Arti buffers data by default due to the design of the Tor protocol, so flushing the
//! // buffer is usually required.
//! // Arti buffers data, so flushing the buffer is usually required.
//! stream.flush().await?;
//!
//! // Read and print the result.
@ -133,6 +134,9 @@
//!
//! `async-std` -- Build with support for the `async_std` backend.
//!
//! `static` -- Link with static versions of your system dependencies,
//! including sqlite and/or openssl.
//!
//! `experimental-api` -- Build with experimental, unstable API support.
//! Note that these APIs are NOT covered by semantic versioning guarantees:
//! we might break them or remove them between patch versions.