use anyhow::Result;
use async_trait::async_trait;
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
#[cfg(feature = "test-support")]
use mockall::automock;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TagValue {
pub tag_id: String,
pub value: String,
pub quality: String,
pub timestamp: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum OpcValue {
String(String),
Int(i32),
Float(f64),
Bool(bool),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WriteResult {
pub tag_id: String,
pub success: bool,
pub error: Option<String>,
}
#[cfg_attr(feature = "test-support", automock)]
#[async_trait]
pub trait OpcProvider: Send + Sync {
async fn list_servers(&self, host: &str) -> Result<Vec<String>>;
async fn browse_tags(
&self,
server: &str,
max_tags: usize,
progress: Arc<AtomicUsize>,
tags_sink: Arc<std::sync::Mutex<Vec<String>>>,
) -> Result<Vec<String>>;
async fn read_tag_values(&self, server: &str, tag_ids: Vec<String>) -> Result<Vec<TagValue>>;
async fn write_tag_value(
&self,
server: &str,
tag_id: &str,
value: OpcValue,
) -> Result<WriteResult>;
}