From 39a2a5101f0d49a7154c7807c2eb82466de3fc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Wed, 14 Aug 2024 08:33:01 +0200 Subject: [PATCH] codewide: migrate doctests to new deser API --- scylla/src/lib.rs | 26 ++- scylla/src/transport/execution_profile.rs | 12 +- scylla/src/transport/iterator.rs | 3 +- scylla/src/transport/session.rs | 72 ++++---- scylla/src/transport/session_builder.rs | 212 +++++++++++----------- 5 files changed, 160 insertions(+), 165 deletions(-) diff --git a/scylla/src/lib.rs b/scylla/src/lib.rs index 7b942c85cc..cbbf795254 100644 --- a/scylla/src/lib.rs +++ b/scylla/src/lib.rs @@ -17,15 +17,15 @@ //! `Session` is created by specifying a few known nodes and connecting to them: //! //! ```rust,no_run -//! use scylla::{LegacySession, SessionBuilder}; +//! use scylla::{Session, SessionBuilder}; //! use std::error::Error; //! //! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! let session: LegacySession = SessionBuilder::new() +//! let session: Session = SessionBuilder::new() //! .known_node("127.0.0.1:9042") //! .known_node("1.2.3.4:9876") -//! .build_legacy() +//! .build() //! .await?; //! //! Ok(()) @@ -50,9 +50,9 @@ //! //! The easiest way to specify bound values in a query is using a tuple: //! ```rust -//! # use scylla::LegacySession; +//! # use scylla::Session; //! # use std::error::Error; -//! # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { +//! # async fn check_only_compiles(session: &Session) -> Result<(), Box> { //! // Insert an int and text into the table //! session //! .query_unpaged( @@ -70,22 +70,20 @@ //! The easiest way to read rows returned by a query is to cast each row to a tuple of values: //! //! ```rust -//! # use scylla::LegacySession; +//! # use scylla::Session; //! # use std::error::Error; -//! # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { -//! use scylla::IntoTypedRows; +//! # async fn check_only_compiles(session: &Session) -> Result<(), Box> { //! //! // Read rows containing an int and text //! // Keep in mind that all results come in one response (no paging is done!), //! // so the memory footprint and latency may be huge! //! // To prevent that, use `Session::query_iter` or `Session::query_single_page`. -//! let rows_opt = session -//! .query_unpaged("SELECT a, b FROM ks.tab", &[]) -//! .await? -//! .rows; +//! let query_result = session +//! .query_unpaged("SELECT a, b FROM ks.tab", &[]) +//! .await?; //! -//! if let Some(rows) = rows_opt { -//! for row in rows.into_typed::<(i32, String)>() { +//! if let Some(rows) = query_result.maybe_rows::<(i32, String)>()? { +//! for row in rows { //! // Parse row as int and text \ //! let (int_val, text_val): (i32, String) = row?; //! } diff --git a/scylla/src/transport/execution_profile.rs b/scylla/src/transport/execution_profile.rs index e977fe81ac..7b7a14faaf 100644 --- a/scylla/src/transport/execution_profile.rs +++ b/scylla/src/transport/execution_profile.rs @@ -16,7 +16,7 @@ //! # extern crate scylla; //! # use std::error::Error; //! # async fn check_only_compiles() -> Result<(), Box> { -//! use scylla::{LegacySession, SessionBuilder}; +//! use scylla::{Session, SessionBuilder}; //! use scylla::statement::Consistency; //! use scylla::transport::ExecutionProfile; //! @@ -27,10 +27,10 @@ //! //! let handle = profile.into_handle(); //! -//! let session: LegacySession = SessionBuilder::new() +//! let session: Session = SessionBuilder::new() //! .known_node("127.0.0.1:9042") //! .default_execution_profile_handle(handle) -//! .build_legacy() +//! .build() //! .await?; //! # Ok(()) //! # } @@ -109,7 +109,7 @@ //! # extern crate scylla; //! # use std::error::Error; //! # async fn check_only_compiles() -> Result<(), Box> { -//! use scylla::{LegacySession, SessionBuilder}; +//! use scylla::{Session, SessionBuilder}; //! use scylla::query::Query; //! use scylla::statement::Consistency; //! use scylla::transport::ExecutionProfile; @@ -125,10 +125,10 @@ //! let mut handle1 = profile1.clone().into_handle(); //! let mut handle2 = profile2.clone().into_handle(); //! -//! let session: LegacySession = SessionBuilder::new() +//! let session: Session = SessionBuilder::new() //! .known_node("127.0.0.1:9042") //! .default_execution_profile_handle(handle1.clone()) -//! .build_legacy() +//! .build() //! .await?; //! //! let mut query1 = Query::from("SELECT * FROM ks.table"); diff --git a/scylla/src/transport/iterator.rs b/scylla/src/transport/iterator.rs index 5f887c9940..cb783a7b83 100644 --- a/scylla/src/transport/iterator.rs +++ b/scylla/src/transport/iterator.rs @@ -575,8 +575,7 @@ impl RawIterator { /// /// # Example /// - /// // FIXME: change `text` to `rust` when Session API is migrated to the new deserialization framework. - /// ```text + /// ```rust /// # use scylla::Session; /// # use std::error::Error; /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { diff --git a/scylla/src/transport/session.rs b/scylla/src/transport/session.rs index cd6a44edb4..02afb1dd69 100644 --- a/scylla/src/transport/session.rs +++ b/scylla/src/transport/session.rs @@ -508,9 +508,9 @@ impl GenericSession { /// /// # Examples /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// // Insert an int and text into a table. /// session /// .query_unpaged( @@ -522,23 +522,22 @@ impl GenericSession { /// # } /// ``` /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::IntoTypedRows; /// /// // Read rows containing an int and text. /// // Keep in mind that all results come in one response (no paging is done!), /// // so the memory footprint and latency may be huge! /// // To prevent that, use `Session::query_iter` or `Session::query_single_page`. - /// let rows_opt = session - /// .query_unpaged("SELECT a, b FROM ks.tab", &[]) - /// .await? - /// .rows; - /// - /// if let Some(rows) = rows_opt { - /// for row in rows.into_typed::<(i32, String)>() { - /// // Parse row as int and text \ + /// let query_result = session + /// .query_unpaged("SELECT a, b FROM ks.tab", &[]) + /// .await?; + /// + /// if let Some(rows) = query_result.maybe_rows::<(i32, String)>()? { + /// for row in rows { + /// // Parse row as int and text. /// let (int_val, text_val): (i32, String) = row?; /// } /// } @@ -568,9 +567,9 @@ impl GenericSession { /// # Example /// /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use std::ops::ControlFlow; /// use scylla::statement::PagingState; /// @@ -582,7 +581,7 @@ impl GenericSession { /// .await?; /// /// // Do something with a single page of results. - /// for row in res.rows_typed::<(i32, String)>()? { + /// for row in res.rows::<(i32, String)>()? { /// let (a, b) = row?; /// } /// @@ -632,16 +631,16 @@ impl GenericSession { /// # Example /// /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::IntoTypedRows; /// use futures::stream::StreamExt; /// /// let mut rows_stream = session /// .query_iter("SELECT a, b FROM ks.t", &[]) /// .await? - /// .into_typed::<(i32, i32)>(); + /// .into_typed::<(i32, i32)>()?; /// /// while let Some(next_row_res) = rows_stream.next().await { /// let (a, b): (i32, i32) = next_row_res?; @@ -685,9 +684,9 @@ impl GenericSession { /// /// # Example /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::prepared_statement::PreparedStatement; /// /// // Prepare the query for later execution @@ -721,9 +720,9 @@ impl GenericSession { /// # Example /// /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use std::ops::ControlFlow; /// use scylla::query::Query; /// use scylla::statement::{PagingState, PagingStateResponse}; @@ -743,7 +742,7 @@ impl GenericSession { /// .await?; /// /// // Do something with a single page of results. - /// for row in res.rows_typed::<(i32, String)>()? { + /// for row in res.rows::<(i32, String)>()? { /// let (a, b) = row?; /// } /// @@ -789,12 +788,11 @@ impl GenericSession { /// # Example /// /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::prepared_statement::PreparedStatement; /// use scylla::IntoTypedRows; - /// use futures::stream::StreamExt; /// /// // Prepare the query for later execution /// let prepared: PreparedStatement = session @@ -805,7 +803,7 @@ impl GenericSession { /// let mut rows_stream = session /// .execute_iter(prepared, &[]) /// .await? - /// .into_typed::<(i32, i32)>(); + /// .into_typed::<(i32, i32)>()?; /// /// while let Some(next_row_res) = rows_stream.next().await { /// let (a, b): (i32, i32) = next_row_res?; @@ -841,9 +839,9 @@ impl GenericSession { /// /// # Example /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::batch::Batch; /// /// let mut batch: Batch = Default::default(); @@ -970,13 +968,13 @@ where /// ```rust /// # use std::error::Error; /// # async fn check_only_compiles() -> Result<(), Box> { - /// use scylla::{LegacySession, SessionConfig}; + /// use scylla::{Session, SessionConfig}; /// use scylla::transport::KnownNode; /// /// let mut config = SessionConfig::new(); /// config.known_nodes.push(KnownNode::Hostname("127.0.0.1:9042".to_string())); /// - /// let session: LegacySession = LegacySession::connect(config).await?; + /// let session: Session = Session::connect(config).await?; /// # Ok(()) /// # } /// ``` @@ -1303,9 +1301,9 @@ where /// /// # Example /// ```rust - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::prepared_statement::PreparedStatement; /// /// // Prepare the query for later execution @@ -1631,9 +1629,9 @@ where /// /// # Example /// ```rust /// # extern crate scylla; - /// # use scylla::LegacySession; + /// # use scylla::Session; /// # use std::error::Error; - /// # async fn check_only_compiles(session: &LegacySession) -> Result<(), Box> { + /// # async fn check_only_compiles(session: &Session) -> Result<(), Box> { /// use scylla::batch::Batch; /// /// // Create a batch statement with unprepared statements @@ -1692,10 +1690,10 @@ where /// * `case_sensitive` - if set to true the generated query will put keyspace name in quotes /// # Example /// ```rust - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::Compression; /// # async fn example() -> Result<(), Box> { - /// # let session = SessionBuilder::new().known_node("127.0.0.1:9042").build_legacy().await?; + /// # let session = SessionBuilder::new().known_node("127.0.0.1:9042").build().await?; /// session /// .query_unpaged("INSERT INTO my_keyspace.tab (a) VALUES ('test1')", &[]) /// .await?; diff --git a/scylla/src/transport/session_builder.rs b/scylla/src/transport/session_builder.rs index 768c0256fe..ea6c24c587 100644 --- a/scylla/src/transport/session_builder.rs +++ b/scylla/src/transport/session_builder.rs @@ -58,13 +58,13 @@ pub type CloudSessionBuilder = GenericSessionBuilder; /// # Example /// /// ``` -/// # use scylla::{LegacySession, SessionBuilder}; +/// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::Compression; /// # async fn example() -> Result<(), Box> { -/// let session: LegacySession = SessionBuilder::new() +/// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .compression(Some(Compression::Snappy)) -/// .build_legacy() +/// .build() /// .await?; /// # Ok(()) /// # } @@ -93,22 +93,22 @@ impl GenericSessionBuilder { /// Add a known node with a hostname /// # Examples /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } /// ``` /// /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("db1.example.com") - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -121,12 +121,12 @@ impl GenericSessionBuilder { /// Add a known node with an IP address /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use std::net::{SocketAddr, IpAddr, Ipv4Addr}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node_addr(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 9042)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -139,11 +139,11 @@ impl GenericSessionBuilder { /// Add a list of known nodes with hostnames /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_nodes(["127.0.0.1:9042", "db1.example.com"]) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -156,15 +156,15 @@ impl GenericSessionBuilder { /// Add a list of known nodes with IP addresses /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use std::net::{SocketAddr, IpAddr, Ipv4Addr}; /// # async fn example() -> Result<(), Box> { /// let addr1 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(172, 17, 0, 3)), 9042); /// let addr2 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(172, 17, 0, 4)), 9042); /// - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_nodes_addr([addr1, addr2]) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -182,14 +182,14 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::Compression; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .use_keyspace("my_keyspace_name", false) /// .user("cassandra", "cassandra") - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -208,7 +208,7 @@ impl GenericSessionBuilder { /// ``` /// # use std::sync::Arc; /// use bytes::Bytes; - /// use scylla::{LegacySession, SessionBuilder}; + /// use scylla::{Session, SessionBuilder}; /// use async_trait::async_trait; /// use scylla::authentication::{AuthenticatorProvider, AuthenticatorSession, AuthError}; /// # use scylla::transport::Compression; @@ -236,12 +236,12 @@ impl GenericSessionBuilder { /// } /// /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .use_keyspace("my_keyspace_name", false) /// .user("cassandra", "cassandra") /// .authenticator_provider(Arc::new(CustomAuthenticatorProvider)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -262,7 +262,7 @@ impl GenericSessionBuilder { /// # use async_trait::async_trait; /// # use std::net::SocketAddr; /// # use std::sync::Arc; - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::session::{AddressTranslator, TranslationError}; /// # use scylla::transport::topology::UntranslatedPeer; /// struct IdentityTranslator; @@ -278,10 +278,10 @@ impl GenericSessionBuilder { /// } /// /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .address_translator(Arc::new(IdentityTranslator)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -292,7 +292,7 @@ impl GenericSessionBuilder { /// # use std::sync::Arc; /// # use std::collections::HashMap; /// # use std::str::FromStr; - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::session::{AddressTranslator, TranslationError}; /// # /// # async fn example() -> Result<(), Box> { @@ -300,10 +300,10 @@ impl GenericSessionBuilder { /// let addr_before_translation = SocketAddr::from_str("192.168.0.42:19042").unwrap(); /// let addr_after_translation = SocketAddr::from_str("157.123.12.42:23203").unwrap(); /// translation_rules.insert(addr_before_translation, addr_after_translation); - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .address_translator(Arc::new(translation_rules)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -323,7 +323,7 @@ impl GenericSessionBuilder { /// ``` /// # use std::fs; /// # use std::path::PathBuf; - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use openssl::ssl::{SslContextBuilder, SslVerifyMode, SslMethod, SslFiletype}; /// # async fn example() -> Result<(), Box> { /// let certdir = fs::canonicalize(PathBuf::from("./examples/certs/scylla.crt"))?; @@ -331,10 +331,10 @@ impl GenericSessionBuilder { /// context_builder.set_certificate_file(certdir.as_path(), SslFiletype::PEM)?; /// context_builder.set_verify(SslVerifyMode::NONE); /// - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .ssl_context(Some(context_builder.build())) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -346,8 +346,8 @@ impl GenericSessionBuilder { } } -// NOTE: this `impl` block contains configuration options specific for **Cloud** [`LegacySession`]. -// This means that if an option fits both non-Cloud and Cloud `LegacySession`s, it should NOT be put +// NOTE: this `impl` block contains configuration options specific for **Cloud** [`Session`]. +// This means that if an option fits both non-Cloud and Cloud `Session`s, it should NOT be put // here, but rather in `impl GenericSessionBuilder` block. #[cfg(feature = "cloud")] impl CloudSessionBuilder { @@ -382,13 +382,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::Compression; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .compression(Some(Compression::Snappy)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -403,13 +403,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use std::time::Duration; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .schema_agreement_interval(Duration::from_secs(5)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -423,17 +423,17 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{statement::Consistency, ExecutionProfile, LegacySession, SessionBuilder}; + /// # use scylla::{statement::Consistency, ExecutionProfile, Session, SessionBuilder}; /// # use std::time::Duration; /// # async fn example() -> Result<(), Box> { /// let execution_profile = ExecutionProfile::builder() /// .consistency(Consistency::All) /// .request_timeout(Some(Duration::from_secs(2))) /// .build(); - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .default_execution_profile_handle(execution_profile.into_handle()) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -451,12 +451,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .tcp_nodelay(true) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -474,12 +474,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .tcp_keepalive_interval(std::time::Duration::from_secs(42)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -502,13 +502,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::Compression; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .use_keyspace("my_keyspace_name", false) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -532,7 +532,7 @@ impl GenericSessionBuilder { /// let session: LegacySession = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .compression(Some(Compression::Snappy)) - /// .build_legacy() // Turns SessionBuilder into Session + /// .build_legacy() // Turns SessionBuilder into LegacySession /// .await?; /// # Ok(()) /// # } @@ -546,7 +546,7 @@ impl GenericSessionBuilder { /// Builds the Session after setting all the options. /// /// The new session object uses the new deserialization API. If you wish - /// to use the old API, use [`SessionBuilder::build_legacy`]. + /// to use the old API, use [`SessionBuilder::build`]. /// /// # Example /// ``` @@ -573,13 +573,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use std::time::Duration; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .connection_timeout(Duration::from_secs(30)) - /// .build_legacy() // Turns SessionBuilder into Session + /// .build() // Turns SessionBuilder into Session /// .await?; /// # Ok(()) /// # } @@ -594,17 +594,17 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { /// use std::num::NonZeroUsize; /// use scylla::transport::session::PoolSize; /// /// // This session will establish 4 connections to each node. /// // For Scylla clusters, this number will be divided across shards - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .pool_size(PoolSize::PerHost(NonZeroUsize::new(4).unwrap())) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -638,12 +638,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .disallow_shard_aware_port(true) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -658,12 +658,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .keyspaces_to_fetch(["my_keyspace"]) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -681,12 +681,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .fetch_schema_metadata(true) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -704,12 +704,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .keepalive_interval(std::time::Duration::from_secs(42)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -734,12 +734,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .keepalive_timeout(std::time::Duration::from_secs(42)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -761,12 +761,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .schema_agreement_timeout(std::time::Duration::from_secs(120)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -781,12 +781,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .auto_await_schema_agreement(false) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -809,16 +809,16 @@ impl GenericSessionBuilder { /// # use async_trait::async_trait; /// # use std::net::SocketAddr; /// # use std::sync::Arc; - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::session::{AddressTranslator, TranslationError}; /// # use scylla::transport::host_filter::DcHostFilter; /// /// # async fn example() -> Result<(), Box> { /// // The session will only connect to nodes from "my-local-dc" - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .host_filter(Arc::new(DcHostFilter::new("my-local-dc".to_string()))) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -833,12 +833,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .refresh_metadata_on_auto_schema_agreement(true) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -861,13 +861,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use std::num::NonZeroU32; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .tracing_info_fetch_attempts(NonZeroU32::new(10).unwrap()) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -890,13 +890,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use std::time::Duration; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .tracing_info_fetch_interval(Duration::from_millis(50)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -912,12 +912,12 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder, statement::Consistency}; + /// # use scylla::{Session, SessionBuilder, statement::Consistency}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .tracing_info_fetch_consistency(Consistency::One) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -942,13 +942,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::Compression; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .write_coalescing(false) // Enabled by default - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -967,12 +967,12 @@ impl GenericSessionBuilder { /// means that the metadata is refreshed every 20 seconds. /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # async fn example() -> Result<(), Box> { - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .cluster_metadata_refresh_interval(std::time::Duration::from_secs(20)) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # } @@ -990,13 +990,13 @@ impl GenericSessionBuilder { /// /// # Example /// ``` - /// # use scylla::{LegacySession, SessionBuilder}; + /// # use scylla::{Session, SessionBuilder}; /// # use scylla::transport::SelfIdentity; /// # async fn example() -> Result<(), Box> { /// let (app_major, app_minor, app_patch) = (2, 1, 3); /// let app_version = format!("{app_major}.{app_minor}.{app_patch}"); /// - /// let session: LegacySession = SessionBuilder::new() + /// let session: Session = SessionBuilder::new() /// .known_node("127.0.0.1:9042") /// .custom_identity( /// SelfIdentity::new() @@ -1004,7 +1004,7 @@ impl GenericSessionBuilder { /// .with_application_name("my-app") /// .with_application_version(app_version) /// ) - /// .build_legacy() + /// .build() /// .await?; /// # Ok(()) /// # }