use std::net::IpAddr;
use uuid::Uuid;
use crate::error::CassandraResult;
use crate::pool::CassandraPool;
pub struct VirtualTables<'a> {
#[allow(dead_code)]
pool: &'a CassandraPool,
}
impl<'a> VirtualTables<'a> {
pub fn new(pool: &'a CassandraPool) -> Self {
Self { pool }
}
pub async fn cluster_info(&self) -> CassandraResult<ClusterInfo> {
Err(crate::error::CassandraError::Query(
"virtual_tables::cluster_info not yet wired".into(),
))
}
pub async fn peers(&self) -> CassandraResult<Vec<PeerInfo>> {
Err(crate::error::CassandraError::Query(
"virtual_tables::peers not yet wired".into(),
))
}
pub async fn settings(&self) -> CassandraResult<Vec<(String, String)>> {
Err(crate::error::CassandraError::Query(
"virtual_tables::settings not yet wired".into(),
))
}
}
#[derive(Debug, Clone)]
pub struct ClusterInfo {
pub cluster_name: String,
pub partitioner: String,
pub release_version: String,
}
#[derive(Debug, Clone)]
pub struct PeerInfo {
pub peer: IpAddr,
pub data_center: String,
pub host_id: Uuid,
pub rack: String,
pub release_version: String,
}
#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;
#[test]
fn test_cluster_info_debug() {
let ci = ClusterInfo {
cluster_name: "Test Cluster".into(),
partitioner: "Murmur3Partitioner".into(),
release_version: "4.1.0".into(),
};
let dbg = format!("{:?}", ci);
assert!(dbg.contains("Test Cluster"));
}
#[test]
fn test_peer_info_construction() {
let pi = PeerInfo {
peer: IpAddr::from_str("192.168.1.1").unwrap(),
data_center: "dc1".into(),
host_id: Uuid::nil(),
rack: "rack1".into(),
release_version: "4.1.0".into(),
};
assert_eq!(pi.data_center, "dc1");
}
}