mirror of
https://github.com/ruvnet/RuView
synced 2026-08-10 20:31:42 +00:00
Squashed 'vendor/ruvector/' content from commit b64c2172
git-subtree-dir: vendor/ruvector git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
//! Zenoh middleware integration
|
||||
//!
|
||||
//! Provides pub/sub, RPC, and discovery with 4-6 byte wire overhead
|
||||
|
||||
use crate::error::Result;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
use tracing::info;
|
||||
|
||||
/// Zenoh session wrapper
|
||||
pub struct Zenoh {
|
||||
_config: ZenohConfig,
|
||||
_inner: Arc<RwLock<()>>, // Placeholder for actual Zenoh session
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ZenohConfig {
|
||||
pub mode: String,
|
||||
pub connect: Vec<String>,
|
||||
pub listen: Vec<String>,
|
||||
}
|
||||
|
||||
impl Default for ZenohConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
mode: "peer".to_string(),
|
||||
connect: vec![],
|
||||
listen: vec!["tcp/0.0.0.0:7447".to_string()],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Zenoh {
|
||||
/// Create a new Zenoh session
|
||||
pub async fn new(config: ZenohConfig) -> Result<Self> {
|
||||
info!("Initializing Zenoh middleware in {} mode", config.mode);
|
||||
|
||||
// In a real implementation, this would initialize Zenoh
|
||||
// For now, we create a placeholder
|
||||
Ok(Self {
|
||||
_config: config,
|
||||
_inner: Arc::new(RwLock::new(())),
|
||||
})
|
||||
}
|
||||
|
||||
/// Create Zenoh with default configuration
|
||||
pub async fn open() -> Result<Self> {
|
||||
Self::new(ZenohConfig::default()).await
|
||||
}
|
||||
|
||||
/// Get the configuration
|
||||
pub fn config(&self) -> &ZenohConfig {
|
||||
&self._config
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_zenoh_creation() {
|
||||
let zenoh = Zenoh::open().await;
|
||||
assert!(zenoh.is_ok());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user