Skip to content

Commit f1aba10

Browse files
authored
Merge pull request #171 from estie-inc/refactor/tidy-imports-and-doc-comments
refactor: alias std paths and reflow doc comments
2 parents a20e56c + 186ed1f commit f1aba10

32 files changed

Lines changed: 281 additions & 392 deletions

benches/result_table.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ fn materialize_dynamic_rows(table: &ResultTable) {
3939
}
4040

4141
fn synthetic_chunk_bytes(row_count: usize, null_pct: u8, escaped_pct: u8) -> Bytes {
42-
// remote chunk fragment shape: `[..],[..],[..]`. Each row is
43-
// [int_text, string_text, timestamp_text].
42+
// remote chunk fragment shape: `[..],[..],[..]`. Each row is [int_text, string_text, timestamp_text].
4443
let mut out = Vec::with_capacity(row_count * 64);
4544
for i in 0..row_count {
4645
if i > 0 {

derive/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub(crate) enum RenameAll {
99
pub(crate) struct ContainerAttrs {
1010
/// Effective field-name conversion.
1111
pub(crate) rename_all: RenameAll,
12-
/// `true` only if the user wrote `#[snowflake(rename_all = "...")]`
13-
/// explicitly. Used to reject `positional` + explicit `rename_all`.
12+
/// `true` only if the user wrote `#[snowflake(rename_all = "...")]` explicitly.
13+
/// Used to reject `positional` + explicit `rename_all`.
1414
pub(crate) rename_all_explicit: bool,
1515
pub(crate) positional: bool,
1616
pub(crate) crate_path: Path,

derive/src/input.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use quote::format_ident;
22
use syn::{Data, DeriveInput, Fields, Ident, Path, Result, spanned::Spanned};
33

4-
use crate::attrs::{ContainerAttrs, parse_container_attrs, parse_field_attrs};
5-
use crate::naming::{apply_rename_all, logical_ident_name};
4+
use crate::{
5+
attrs::{ContainerAttrs, parse_container_attrs, parse_field_attrs},
6+
naming::{apply_rename_all, logical_ident_name},
7+
};
68

79
pub(crate) struct FromRowDerive {
810
pub(crate) struct_ident: Ident,

src/auth/external_browser/config.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ impl ManualRedirectConfig {
8787
#[derive(Clone, Debug, PartialEq, Eq)]
8888
/// Configuration for [`AuthConfig::external_browser`](crate::AuthConfig::external_browser).
8989
///
90-
/// Use [`ExternalBrowserConfig::callback_listener`] or
91-
/// [`ExternalBrowserConfig::manual_redirect`] to choose the
92-
/// authentication mode.
90+
/// Use [`ExternalBrowserConfig::callback_listener`] or [`ExternalBrowserConfig::manual_redirect`] to choose the authentication mode.
9391
/// For end-to-end setup examples, see [`AuthConfig::external_browser`](crate::AuthConfig::external_browser).
9492
pub struct ExternalBrowserConfig {
9593
mode: ExternalBrowserMode,
@@ -121,12 +119,9 @@ impl ExternalBrowserConfig {
121119
/// This mode starts a local HTTP listener and receives the token automatically
122120
/// from the redirected callback URL.
123121
///
124-
/// - `browser_launch_mode`: controls whether the auth URL is opened automatically (`Auto`)
125-
/// or only printed for manual open (`Manual`).
126-
/// - `callback_socket_addr`: bind address for the local callback listener
127-
/// (for example `127.0.0.1` or `0.0.0.0`).
128-
/// - `callback_socket_port`: bind port for the callback listener.
129-
/// Use `0` to let the OS pick an available ephemeral port.
122+
/// - `browser_launch_mode`: controls whether the auth URL is opened automatically (`Auto`) or only printed for manual open (`Manual`).
123+
/// - `callback_socket_addr`: bind address for the local callback listener (for example `127.0.0.1` or `0.0.0.0`).
124+
/// - `callback_socket_port`: bind port for the callback listener. Use `0` to let the OS pick an available ephemeral port.
130125
pub fn callback_listener(
131126
browser_launch_mode: BrowserLaunchMode,
132127
callback_socket_addr: IpAddr,
@@ -143,17 +138,12 @@ impl ExternalBrowserConfig {
143138

144139
/// Creates a manual-redirect external-browser configuration.
145140
///
146-
/// This mode does not start a local listener. After login, paste the redirected
147-
/// URL shown by the browser into the terminal prompt.
141+
/// This mode does not start a local listener. After login, paste the redirected URL shown by the browser into the terminal prompt.
148142
///
149-
/// - `browser_launch_mode`: controls whether the auth URL is opened automatically (`Auto`)
150-
/// or only printed for manual open (`Manual`).
151-
/// - `redirect_port`: port embedded in `BROWSER_MODE_REDIRECT_PORT` for Snowflake.
152-
/// No local server is started in this mode, so this port does not need to be
153-
/// actually listening.
154-
/// It is still required because Snowflake uses this value to construct the
155-
/// browser redirect URL that you later paste into the terminal; the connector
156-
/// then extracts the token from that pasted URL.
143+
/// - `browser_launch_mode`: controls whether the auth URL is opened automatically (`Auto`) or only printed for manual open (`Manual`).
144+
/// - `redirect_port`: port embedded in `BROWSER_MODE_REDIRECT_PORT` for Snowflake. No local server is started in this mode,
145+
/// so this port does not need to be actually listening. It is still required because Snowflake uses this value to construct
146+
/// the browser redirect URL that you later paste into the terminal; the connector then extracts the token from that pasted URL.
157147
pub fn manual_redirect(
158148
browser_launch_mode: BrowserLaunchMode,
159149
redirect_port: NonZeroU16,

src/auth/external_browser/manual_input_unix.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ use crate::{Result, error::AuthError};
99
pub(super) fn try_read_redirected_url_line_noncanonical() -> Option<Result<String>> {
1010
let stdin = io::stdin();
1111

12-
// We intentionally use nix termios wrappers (instead of raw libc calls) so this crate
13-
// can avoid `unsafe` while still controlling TTY mode.
14-
// On macOS, canonical mode has a small line-length limit (MAX_CANON), so long redirected
15-
// URLs can trigger terminal bell/input rejection. Non-canonical mode avoids that limit.
12+
// We intentionally use nix termios wrappers so this crate can avoid `unsafe` while still controlling TTY mode.
13+
// On macOS, canonical mode has a small line-length limit (MAX_CANON), so long redirected URLs can trigger terminal
14+
// bell/input rejection. Non-canonical mode avoids that limit.
1615
if !stdin.is_terminal() {
1716
// Only switch modes for interactive TTY. If stdin is redirected/piped, keep default read_line.
1817
return None;

src/auth/external_browser/payload.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ impl ParsedTokenAndConsent {
2727
/// - callback listener flow (`GET` query / `POST` form body parsing in `listener`)
2828
/// - manual redirected-URL flow (query/fragment parsing in `manual_redirect_input`)
2929
///
30-
/// Keeping this in one place guarantees both flows use identical parsing rules
31-
/// (case-insensitive keys, first non-empty token wins, consent parsing behavior).
30+
/// Keeping this in one place guarantees both flows use identical parsing rules.
3231
pub(crate) fn parse_token_and_consent_from_pairs<'a, I>(pairs: I) -> ParsedTokenAndConsent
3332
where
3433
I: IntoIterator<Item = (Cow<'a, str>, Cow<'a, str>)>,

src/auth/wire/login_request.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ pub(crate) enum LoginCredentialWire<'a> {
6565
pub(crate) enum PasscodeWire<'a> {
6666
/// Sent as a separate `PASSCODE` field.
6767
Separate(&'a str),
68-
/// The passcode is already appended to `PASSWORD`; only the method flag is
69-
/// sent.
68+
/// The passcode is already appended to `PASSWORD`; only the method flag is sent.
7069
InPassword,
7170
}
7271

src/bind.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! Types passed to [`Statement::bind`](crate::Statement::bind) and
2-
//! [`Statement::bind_named`](crate::Statement::bind_named).
1+
//! Types passed to [`Statement::bind`](crate::Statement::bind) and [`Statement::bind_named`](crate::Statement::bind_named).
32
//!
43
//! Most callers reach for one of the typed wrappers.
54
//! [`RawBind`] is the escape hatch when none of those fit (e.g. binding a `DECFLOAT`).

src/config.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ pub enum EndpointConfig {
6767

6868
/// HTTP transport-layer options.
6969
///
70-
/// Configures how requests are physically delivered to Snowflake,
71-
/// independent of which endpoint they target.
70+
/// Configures how requests are physically delivered to Snowflake, independent of which endpoint they target.
7271
#[derive(Default, Clone, Debug)]
7372
pub struct TransportConfig {
7473
proxy: Option<ProxyConfig>,
7574
}
7675

7776
/// Configuration for an HTTP proxy used by [`TransportConfig`].
7877
///
79-
/// Specifies the proxy URL and optional authentication credentials.
80-
/// Only HTTP and HTTPS proxy schemes are accepted.
78+
/// Specifies the proxy URL and optional authentication credentials. Only HTTP and HTTPS proxy schemes are accepted.
8179
#[derive(Clone, Debug)]
8280
pub struct ProxyConfig {
8381
url: Url,

src/error/decode.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use std::borrow::Cow;
1+
use std::{
2+
borrow::Cow,
3+
error::Error as StdError,
4+
fmt::{self, Display},
5+
};
26

37
use crate::result_table::{ColumnIndex, ColumnType};
48

@@ -9,12 +13,11 @@ pub type CellDecodeResult<T> = std::result::Result<T, CellConversionError>;
913

1014
/// Cell-local reason why decoding a value failed.
1115
///
12-
/// This describes only the local conversion problem. Row, column, and
13-
/// value context live on [`CellDecodeError`].
16+
/// This describes only the local conversion problem. Row, column, and value context live on [`CellDecodeError`].
1417
#[derive(Debug)]
1518
pub struct CellConversionError {
1619
reason: Box<str>,
17-
source: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
20+
source: Option<Box<dyn StdError + Send + Sync + 'static>>,
1821
}
1922

2023
impl CellConversionError {
@@ -29,34 +32,31 @@ impl CellConversionError {
2932
&self.reason
3033
}
3134

32-
pub fn source(&self) -> Option<&(dyn std::error::Error + Send + Sync + 'static)> {
35+
pub fn source(&self) -> Option<&(dyn StdError + Send + Sync + 'static)> {
3336
self.source.as_deref()
3437
}
3538
}
3639

37-
impl std::fmt::Display for CellConversionError {
38-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40+
impl Display for CellConversionError {
41+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3942
f.write_str(&self.reason)
4043
}
4144
}
4245

43-
impl std::error::Error for CellConversionError {
44-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
46+
impl StdError for CellConversionError {
47+
fn source(&self) -> Option<&(dyn StdError + 'static)> {
4548
self.source.as_deref().map(|source| source as _)
4649
}
4750
}
4851

4952
#[derive(Debug)]
5053
pub struct CellConversionErrorBuilder {
5154
reason: Box<str>,
52-
source: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
55+
source: Option<Box<dyn StdError + Send + Sync + 'static>>,
5356
}
5457

5558
impl CellConversionErrorBuilder {
56-
pub fn source(
57-
mut self,
58-
source: impl Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
59-
) -> Self {
59+
pub fn source(mut self, source: impl Into<Box<dyn StdError + Send + Sync + 'static>>) -> Self {
6060
self.source = Some(source.into());
6161
self
6262
}
@@ -132,8 +132,8 @@ impl CellDecodeError {
132132
}
133133
}
134134

135-
impl std::fmt::Display for CellDecodeError {
136-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
135+
impl Display for CellDecodeError {
136+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
137137
write!(
138138
f,
139139
"row_index {} column_index {:?} ({}): target_type {}, found {:?}",
@@ -153,10 +153,10 @@ impl std::fmt::Display for CellDecodeError {
153153
}
154154
}
155155

156-
impl std::error::Error for CellDecodeError {
157-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
156+
impl StdError for CellDecodeError {
157+
fn source(&self) -> Option<&(dyn StdError + 'static)> {
158158
self.issue
159159
.source()
160-
.map(|_| &self.issue as &(dyn std::error::Error + 'static))
160+
.map(|_| &self.issue as &(dyn StdError + 'static))
161161
}
162162
}

0 commit comments

Comments
 (0)