Skip to content

Commit 3ec2782

Browse files
committed
compile fixes
1 parent 405cd81 commit 3ec2782

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

questdb-rs/src/ingress/mod.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ enum AsyncConnection {
372372
Tls(Box<tokio_rustls::client::TlsStream<tokio::net::TcpStream>>),
373373
}
374374

375+
#[cfg(feature = "_async-sender")]
376+
enum AsyncProtocolHandler {
377+
#[cfg(feature = "async-sender-tcp")]
378+
AsyncTcp(AsyncConnection),
379+
380+
#[cfg(feature = "async-sender-http")]
381+
AsyncHttp(),
382+
}
383+
375384
#[cfg(feature = "sync-sender-tcp")]
376385
impl SyncConnection {
377386
fn send_key_id(&mut self, key_id: &str) -> Result<()> {
@@ -437,18 +446,13 @@ impl SyncConnection {
437446
}
438447
}
439448

440-
enum ProtocolHandler {
449+
#[cfg(feature = "_sync-sender")]
450+
enum SyncProtocolHandler {
441451
#[cfg(feature = "sync-sender-tcp")]
442452
SyncTcp(SyncConnection),
443453

444454
#[cfg(feature = "sync-sender-http")]
445455
SyncHttp(SyncHttpHandlerState),
446-
447-
#[cfg(feature = "async-sender-tcp")]
448-
AsyncTcp(AsyncConnection),
449-
450-
#[cfg(feature = "async-sender-http")]
451-
AsyncHttp(),
452456
}
453457

454458
#[cfg(feature = "sync-sender-tcp")]
@@ -1412,7 +1416,7 @@ impl Buffer {
14121416
/// * To send messages, call the [`flush`](Sender::flush) method.
14131417
pub struct Sender {
14141418
descr: String,
1415-
handler: ProtocolHandler,
1419+
handler: SyncProtocolHandler,
14161420
connected: bool,
14171421
max_buf_size: usize,
14181422
protocol_version: ProtocolVersion,
@@ -2387,7 +2391,7 @@ impl SenderBuilder {
23872391
}
23882392

23892393
#[cfg(feature = "sync-sender-tcp")]
2390-
fn connect_tcp(&self, auth: &Option<AuthParams>) -> Result<ProtocolHandler> {
2394+
fn connect_tcp(&self, auth: &Option<AuthParams>) -> Result<SyncProtocolHandler> {
23912395
let addr: SockAddr = gai::resolve_host_port(self.host.as_str(), self.port.as_str())?;
23922396
let mut sock = Socket::new(Domain::IPV4, Type::STREAM, Some(SockProtocol::TCP))
23932397
.map_err(|io_err| map_io_to_socket_err("Could not open TCP socket: ", io_err))?;
@@ -2476,7 +2480,7 @@ impl SenderBuilder {
24762480
conn.authenticate(auth)?;
24772481
}
24782482

2479-
Ok(ProtocolHandler::SyncTcp(conn))
2483+
Ok(SyncProtocolHandler::SyncTcp(conn))
24802484
}
24812485

24822486
fn build_auth(&self) -> Result<Option<AuthParams>> {
@@ -2654,7 +2658,7 @@ impl SenderBuilder {
26542658
self.host.deref(),
26552659
self.port.deref()
26562660
);
2657-
ProtocolHandler::SyncHttp(SyncHttpHandlerState {
2661+
SyncProtocolHandler::SyncHttp(SyncHttpHandlerState {
26582662
agent,
26592663
url,
26602664
auth,
@@ -2672,7 +2676,7 @@ impl SenderBuilder {
26722676
Protocol::Tcp | Protocol::Tcps => ProtocolVersion::V1,
26732677
#[cfg(feature = "sync-sender-http")]
26742678
Protocol::Http | Protocol::Https => {
2675-
if let ProtocolHandler::SyncHttp(http_state) = &handler {
2679+
if let SyncProtocolHandler::SyncHttp(http_state) = &handler {
26762680
let settings_url = &format!(
26772681
"{}://{}:{}/settings",
26782682
self.protocol.schema(),
@@ -2938,7 +2942,8 @@ impl Sender {
29382942
return Ok(());
29392943
}
29402944
match self.handler {
2941-
ProtocolHandler::SyncTcp(ref mut conn) => {
2945+
#[cfg(feature = "sync-sender-tcp")]
2946+
SyncProtocolHandler::SyncTcp(ref mut conn) => {
29422947
if transactional {
29432948
return Err(error::fmt!(
29442949
InvalidApiCall,
@@ -2951,7 +2956,7 @@ impl Sender {
29512956
})?;
29522957
}
29532958
#[cfg(feature = "sync-sender-http")]
2954-
ProtocolHandler::SyncHttp(ref state) => {
2959+
SyncProtocolHandler::SyncHttp(ref state) => {
29552960
if transactional && !buf.transactional() {
29562961
return Err(error::fmt!(
29572962
InvalidApiCall,

0 commit comments

Comments
 (0)