pub struct Connector {
pub config: ConnectorConfig,
/* private fields */
}Fields§
§config: ConnectorConfigImplementations§
Source§impl Connector
impl Connector
Sourcepub fn new(config: ConnectorConfig) -> Self
pub fn new(config: ConnectorConfig) -> Self
Create a new connector with an empty cache.
The connector starts disconnected; a persistent connection is
established lazily on the first sync call.
Sourcepub async fn sync(&self) -> Result<usize, String>
pub async fn sync(&self) -> Result<usize, String>
Connect to the remote server, fetch entities, and update cache.
Tries incremental delta sync first (via the changes op) if we have a
known remote version. Falls back to full sync on first connect, when the
remote doesn’t support changes, or when the version gap is too large.
Returns the number of cached entities after sync, or an error string.
Sourcepub fn update_cache(&self, entities: Vec<HDict>)
pub fn update_cache(&self, entities: Vec<HDict>)
Replace the cached entities and rebuild the owned-ID index and bitmap tag index.
Extracts all id Ref values from the given entities into a HashSet,
builds a bitmap tag index for fast filtered reads, then atomically
replaces the cache, ownership set, and index.
Sourcepub fn owns(&self, id: &str) -> bool
pub fn owns(&self, id: &str) -> bool
Returns true if this connector owns an entity with the given ID.
Sourcepub fn get_cached_entity(&self, id: &str) -> Option<Arc<HDict>>
pub fn get_cached_entity(&self, id: &str) -> Option<Arc<HDict>>
Look up a single cached entity by ID using the O(1) id_map index.
Sourcepub fn batch_get_cached(&self, ids: &[&str]) -> (Vec<Arc<HDict>>, Vec<String>)
pub fn batch_get_cached(&self, ids: &[&str]) -> (Vec<Arc<HDict>>, Vec<String>)
Look up multiple cached entities by ID in a single pass. Returns found entities and missing IDs.
Sourcepub fn cached_entities(&self) -> Vec<Arc<HDict>>
pub fn cached_entities(&self) -> Vec<Arc<HDict>>
Returns Arc-wrapped references to all cached entities (cheap pointer copies).
Sourcepub fn entity_count(&self) -> usize
pub fn entity_count(&self) -> usize
Returns the number of cached entities.
Sourcepub fn filter_cached(
&self,
filter_expr: &str,
limit: usize,
) -> Result<Vec<HDict>, String>
pub fn filter_cached( &self, filter_expr: &str, limit: usize, ) -> Result<Vec<HDict>, String>
Filter cached entities using the bitmap tag index for acceleration.
Returns matching entities up to limit (0 = unlimited). Uses the same
two-phase approach as EntityGraph: bitmap candidates → full filter eval.
Sourcepub fn filter_cached_with_ast(
&self,
ast: &FilterNode,
limit: usize,
) -> Vec<Arc<HDict>>
pub fn filter_cached_with_ast( &self, ast: &FilterNode, limit: usize, ) -> Vec<Arc<HDict>>
Filter cached entities using a pre-parsed filter AST.
Avoids redundant parsing when the same filter is applied across multiple connectors (e.g. federated reads). Returns Arc-wrapped references for cheap cloning in federation pipelines.
Sourcepub fn add_remote_watch(&self, prefixed_id: &str)
pub fn add_remote_watch(&self, prefixed_id: &str)
Add a federated entity ID to the remote watch set.
Sourcepub fn remove_remote_watch(&self, prefixed_id: &str)
pub fn remove_remote_watch(&self, prefixed_id: &str)
Remove a federated entity ID from the remote watch set.
Sourcepub fn remote_watch_count(&self) -> usize
pub fn remote_watch_count(&self) -> usize
Returns the number of entity IDs being watched remotely.
Sourcepub fn transport_mode(&self) -> TransportMode
pub fn transport_mode(&self) -> TransportMode
Returns the current transport mode.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns whether the connector is currently connected (last sync succeeded).
Sourcepub fn last_sync_time(&self) -> Option<DateTime<Utc>>
pub fn last_sync_time(&self) -> Option<DateTime<Utc>>
Returns the timestamp of the last successful sync, if any.
Sourcepub fn cache_version(&self) -> u64
pub fn cache_version(&self) -> u64
Returns the current cache version counter.
Sourcepub fn state(&self) -> ConnectorState
pub fn state(&self) -> ConnectorState
Returns an observable snapshot of this connector’s state.
Sourcepub async fn proxy_his_read(
&self,
prefixed_id: &str,
range: &str,
) -> Result<HGrid, String>
pub async fn proxy_his_read( &self, prefixed_id: &str, range: &str, ) -> Result<HGrid, String>
Proxy a hisRead request to the remote server.
Strips the ID prefix, calls hisRead on the remote, and returns the
response grid. Clears the client on connection error.
Sourcepub async fn proxy_point_write(
&self,
prefixed_id: &str,
level: u8,
val: &Kind,
) -> Result<HGrid, String>
pub async fn proxy_point_write( &self, prefixed_id: &str, level: u8, val: &Kind, ) -> Result<HGrid, String>
Proxy a pointWrite request to the remote server.
Strips the ID prefix, calls pointWrite on the remote with the given
level and value. Clears the client on connection error.
Sourcepub async fn proxy_his_write(
&self,
prefixed_id: &str,
items: Vec<HDict>,
) -> Result<HGrid, String>
pub async fn proxy_his_write( &self, prefixed_id: &str, items: Vec<HDict>, ) -> Result<HGrid, String>
Proxy a hisWrite request to the remote server.
Strips the ID prefix, calls hisWrite on the remote with the given
time-series rows. Clears the client on connection error.
Sourcepub async fn proxy_import(&self, entity: &HDict) -> Result<HGrid, String>
pub async fn proxy_import(&self, entity: &HDict) -> Result<HGrid, String>
Proxy an import request for a single entity to the remote server.
Strips the id prefix from the entity, wraps it in a single-row grid,
and calls the remote import op.
Sourcepub async fn proxy_invoke_action(
&self,
prefixed_id: &str,
action: &str,
args: HDict,
) -> Result<HGrid, String>
pub async fn proxy_invoke_action( &self, prefixed_id: &str, action: &str, args: HDict, ) -> Result<HGrid, String>
Proxy an invokeAction request to the remote server.
Strips the ID prefix, calls invokeAction on the remote with the given
action name and arguments dict. Clears the client on connection error.
Sourcepub fn spawn_sync_task(connector: Arc<Connector>) -> JoinHandle<()>
pub fn spawn_sync_task(connector: Arc<Connector>) -> JoinHandle<()>
Spawn a background sync task for this connector.
The task loops forever, syncing entities at the configured interval. On error, the persistent client is cleared to force reconnection on the next iteration.
Auto Trait Implementations§
impl !Freeze for Connector
impl !RefUnwindSafe for Connector
impl Send for Connector
impl Sync for Connector
impl Unpin for Connector
impl UnsafeUnpin for Connector
impl !UnwindSafe for Connector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more