Skip to content

Commit 2731653

Browse files
committed
compile fixes
1 parent 5caf08b commit 2731653

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
@@ -366,6 +366,15 @@ enum AsyncConnection {
366366
Tls(Box<tokio_rustls::client::TlsStream<tokio::net::TcpStream>>),
367367
}
368368

369+
#[cfg(feature = "_async-sender")]
370+
enum AsyncProtocolHandler {
371+
#[cfg(feature = "async-sender-tcp")]
372+
AsyncTcp(AsyncConnection),
373+
374+
#[cfg(feature = "async-sender-http")]
375+
AsyncHttp(),
376+
}
377+
369378
#[cfg(feature = "sync-sender-tcp")]
370379
impl SyncConnection {
371380
fn send_key_id(&mut self, key_id: &str) -> Result<()> {
@@ -431,18 +440,13 @@ impl SyncConnection {
431440
}
432441
}
433442

434-
enum ProtocolHandler {
443+
#[cfg(feature = "_sync-sender")]
444+
enum SyncProtocolHandler {
435445
#[cfg(feature = "sync-sender-tcp")]
436446
SyncTcp(SyncConnection),
437447

438448
#[cfg(feature = "sync-sender-http")]
439449
SyncHttp(SyncHttpHandlerState),
440-
441-
#[cfg(feature = "async-sender-tcp")]
442-
AsyncTcp(AsyncConnection),
443-
444-
#[cfg(feature = "async-sender-http")]
445-
AsyncHttp(),
446450
}
447451

448452
#[cfg(feature = "sync-sender-tcp")]
@@ -1406,7 +1410,7 @@ impl Buffer {
14061410
/// * To send messages, call the [`flush`](Sender::flush) method.
14071411
pub struct Sender {
14081412
descr: String,
1409-
handler: ProtocolHandler,
1413+
handler: SyncProtocolHandler,
14101414
connected: bool,
14111415
max_buf_size: usize,
14121416
protocol_version: ProtocolVersion,
@@ -2381,7 +2385,7 @@ impl SenderBuilder {
23812385
}
23822386

23832387
#[cfg(feature = "sync-sender-tcp")]
2384-
fn connect_tcp(&self, auth: &Option<AuthParams>) -> Result<ProtocolHandler> {
2388+
fn connect_tcp(&self, auth: &Option<AuthParams>) -> Result<SyncProtocolHandler> {
23852389
let addr: SockAddr = gai::resolve_host_port(self.host.as_str(), self.port.as_str())?;
23862390
let mut sock = Socket::new(Domain::IPV4, Type::STREAM, Some(SockProtocol::TCP))
23872391
.map_err(|io_err| map_io_to_socket_err("Could not open TCP socket: ", io_err))?;
@@ -2470,7 +2474,7 @@ impl SenderBuilder {
24702474
conn.authenticate(auth)?;
24712475
}
24722476

2473-
Ok(ProtocolHandler::SyncTcp(conn))
2477+
Ok(SyncProtocolHandler::SyncTcp(conn))
24742478
}
24752479

24762480
fn build_auth(&self) -> Result<Option<AuthParams>> {
@@ -2648,7 +2652,7 @@ impl SenderBuilder {
26482652
self.host.deref(),
26492653
self.port.deref()
26502654
);
2651-
ProtocolHandler::SyncHttp(SyncHttpHandlerState {
2655+
SyncProtocolHandler::SyncHttp(SyncHttpHandlerState {
26522656
agent,
26532657
url,
26542658
auth,
@@ -2666,7 +2670,7 @@ impl SenderBuilder {
26662670
Protocol::Tcp | Protocol::Tcps => ProtocolVersion::V1,
26672671
#[cfg(feature = "sync-sender-http")]
26682672
Protocol::Http | Protocol::Https => {
2669-
if let ProtocolHandler::SyncHttp(http_state) = &handler {
2673+
if let SyncProtocolHandler::SyncHttp(http_state) = &handler {
26702674
let settings_url = &format!(
26712675
"{}://{}:{}/settings",
26722676
self.protocol.schema(),
@@ -2932,7 +2936,8 @@ impl Sender {
29322936
return Ok(());
29332937
}
29342938
match self.handler {
2935-
ProtocolHandler::SyncTcp(ref mut conn) => {
2939+
#[cfg(feature = "sync-sender-tcp")]
2940+
SyncProtocolHandler::SyncTcp(ref mut conn) => {
29362941
if transactional {
29372942
return Err(error::fmt!(
29382943
InvalidApiCall,
@@ -2945,7 +2950,7 @@ impl Sender {
29452950
})?;
29462951
}
29472952
#[cfg(feature = "sync-sender-http")]
2948-
ProtocolHandler::SyncHttp(ref state) => {
2953+
SyncProtocolHandler::SyncHttp(ref state) => {
29492954
if transactional && !buf.transactional() {
29502955
return Err(error::fmt!(
29512956
InvalidApiCall,

0 commit comments

Comments
 (0)