From f41f2c2f9c94417a86b7c89bc27bf5955d9bc1a1 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 25 Sep 2024 05:46:48 +0200 Subject: [PATCH 1/3] fix: mark tests as no_run: they require net access --- src/api/change.rs | 2 +- src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/change.rs b/src/api/change.rs index e844035..fe1e3e2 100644 --- a/src/api/change.rs +++ b/src/api/change.rs @@ -20,7 +20,7 @@ /// To delete a the fourth character we should send a. /// `TextChange { start: 3, end: 4, content: "".into(), hash: None }` /// -/// ```rust +/// ``` /// let change = codemp::api::TextChange { /// start: 6, end: 11, /// content: "mom".to_string(), hash: None diff --git a/src/lib.rs b/src/lib.rs index e84eb6d..2b86f77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ //! The main entrypoint is [`Client::connect`], which establishes an authenticated connection with //! a supported remote server and returns a [`Client`] handle to interact with it. //! -//! ```rust +//! ```no_run //! # async fn main_fn() { //! let client = codemp::Client::connect( //! codemp::api::Config::new( @@ -34,7 +34,7 @@ //! A [`Client`] can acquire a [`Workspace`] handle by joining an existing one it can access with //! [`Client::join_workspace`] or create a new one with [`Client::create_workspace`]. //! -//! ```rust, run +//! ```no_run //! # async fn main_fn() { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! client.create_workspace("my-workspace").await.expect("failed to create workspace!"); @@ -45,7 +45,7 @@ //! A [`Workspace`] handle can be used to acquire a [`cursor::Controller`] to track remote [`api::Cursor`]s //! and one or more [`buffer::Controller`] to send and receive [`api::TextChange`]s. //! -//! ```rust +//! ```no_run //! # async fn main_fn() { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! # client.create_workspace("").await.unwrap(); @@ -61,7 +61,7 @@ //! eventual consistency. Each [`api::TextChange`] is translated in a network counterpart that is //! guaranteed to converge. //! -//! ```rust +//! ```no_run //! # async fn main_fn() { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! # client.create_workspace("").await.unwrap(); From d506d8cc74db2f8d40ebeb2d9319faf76aae8623 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 25 Sep 2024 16:42:09 +0200 Subject: [PATCH 2/3] fix: add ghost main() function for nightly/beta rust doctests --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2b86f77..fa1abf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,7 @@ //! a supported remote server and returns a [`Client`] handle to interact with it. //! //! ```no_run +//! # fn main() {} //! # async fn main_fn() { //! let client = codemp::Client::connect( //! codemp::api::Config::new( @@ -35,6 +36,7 @@ //! [`Client::join_workspace`] or create a new one with [`Client::create_workspace`]. //! //! ```no_run +//! # fn main() {} //! # async fn main_fn() { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! client.create_workspace("my-workspace").await.expect("failed to create workspace!"); @@ -46,6 +48,7 @@ //! and one or more [`buffer::Controller`] to send and receive [`api::TextChange`]s. //! //! ```no_run +//! # fn main() {} //! # async fn main_fn() { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! # client.create_workspace("").await.unwrap(); @@ -62,6 +65,7 @@ //! guaranteed to converge. //! //! ```no_run +//! # fn main() {} //! # async fn main_fn() { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! # client.create_workspace("").await.unwrap(); From d31b3d244a87e0d19906d4afa24ecdf59867b442 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 25 Sep 2024 16:54:54 +0200 Subject: [PATCH 3/3] fix: use async blocks rather than main + async fn --- src/lib.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fa1abf5..c60ac2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,8 +19,7 @@ //! a supported remote server and returns a [`Client`] handle to interact with it. //! //! ```no_run -//! # fn main() {} -//! # async fn main_fn() { +//! # async { //! let client = codemp::Client::connect( //! codemp::api::Config::new( //! "mail@example.net", @@ -29,27 +28,25 @@ //! ) //! .await //! .expect("failed to connect!"); -//! # } +//! # }; //! ``` //! //! A [`Client`] can acquire a [`Workspace`] handle by joining an existing one it can access with //! [`Client::join_workspace`] or create a new one with [`Client::create_workspace`]. //! //! ```no_run -//! # fn main() {} -//! # async fn main_fn() { +//! # async { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! client.create_workspace("my-workspace").await.expect("failed to create workspace!"); //! let workspace = client.join_workspace("my-workspace").await.expect("failed to attach!"); -//! # } +//! # }; //! ``` //! //! A [`Workspace`] handle can be used to acquire a [`cursor::Controller`] to track remote [`api::Cursor`]s //! and one or more [`buffer::Controller`] to send and receive [`api::TextChange`]s. //! //! ```no_run -//! # fn main() {} -//! # async fn main_fn() { +//! # async { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! # client.create_workspace("").await.unwrap(); //! # let workspace = client.join_workspace("").await.unwrap(); @@ -57,7 +54,7 @@ //! let cursor = workspace.cursor(); //! let event = cursor.recv().await.expect("disconnected while waiting for event!"); //! println!("user {} moved on buffer {}", event.user.unwrap_or_default(), event.buffer); -//! # } +//! # }; //! ``` //! //! Internally, [`buffer::Controller`]s store the buffer state as a [diamond_types] CRDT, guaranteeing @@ -65,8 +62,7 @@ //! guaranteed to converge. //! //! ```no_run -//! # fn main() {} -//! # async fn main_fn() { +//! # async { //! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap(); //! # client.create_workspace("").await.unwrap(); //! # let workspace = client.join_workspace("").await.unwrap(); @@ -76,7 +72,7 @@ //! if let Some(change) = buffer.try_recv().await.unwrap() { //! println!("content: {}, span: {}-{}", change.content, change.start, change.end); //! } // if None, no changes are currently available -//! # } +//! # }; //! ``` //! //! ## FFI