Add type for query option

This commit is contained in:
Dominik Werder
2025-07-23 23:54:59 +02:00
parent 89eed68a15
commit cd38c0940c
2 changed files with 37 additions and 0 deletions

View File

@@ -25,7 +25,9 @@ pub enum ChannelStatus {
AssignedToAddress,
Opened,
Closed(ChannelStatusClosedReason),
Ping,
Pong,
PongTimeout,
MonitoringSilenceReadStart,
MonitoringSilenceReadTimeout,
MonitoringSilenceReadUnchanged,
@@ -69,6 +71,8 @@ impl ChannelStatus {
MonitoringReadDiffTime => 33,
MonitoringReadDiffValue => 34,
PollingReadTimeout => 35,
Ping => 36,
PongTimeout => 37,
}
}
@@ -100,6 +104,8 @@ impl ChannelStatus {
33 => MonitoringReadDiffTime,
34 => MonitoringReadDiffValue,
35 => PollingReadTimeout,
36 => Ping,
37 => PongTimeout,
_ => {
return Err(Error::UnknownStatus);
}
@@ -117,7 +123,9 @@ impl ChannelStatus {
AssignedToAddress => "Located",
Opened => "Opened",
Closed(_) => "Closed",
Ping => "Pingg",
Pong => "Pongg",
PongTimeout => "PongTimeout",
MonitoringSilenceReadStart => "MSRS",
MonitoringSilenceReadTimeout => "MSRT",
MonitoringSilenceReadUnchanged => "MSRU",

View File

@@ -4532,3 +4532,32 @@ pub unsafe fn extltref2<'a, 'b, T>(t: &'a T) -> &'b T {
pub unsafe fn extltmut<'a, 'b, T>(t: &'a mut T) -> &'b mut T {
unsafe { core::mem::transmute(t) }
}
#[derive(Debug, Clone)]
pub struct UseScylla6Workarounds(pub bool);
impl Default for UseScylla6Workarounds {
fn default() -> Self {
Self(true)
}
}
impl std::ops::Deref for UseScylla6Workarounds {
type Target = bool;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<Option<u32>> for UseScylla6Workarounds {
fn from(value: Option<u32>) -> Self {
value.map_or(Default::default(), |x| {
if x == 0 {
UseScylla6Workarounds(false)
} else {
UseScylla6Workarounds(true)
}
})
}
}