pub struct Subscription {
pub collection: String,
pub query: Query,
pub qos: SubscriptionQoS,
}Expand description
Subscription configuration with QoS policy
Combines a collection, query filter, and QoS settings for fine-grained control over what data syncs and how it syncs.
§Example
use peat_mesh::sync::types::{Subscription, Query, GeoPoint, SubscriptionQoS};
use peat_mesh::qos::SyncMode;
// Subscribe to nearby beacons with LatestOnly sync
let subscription = Subscription {
collection: "beacons".to_string(),
query: Query::WithinRadius {
center: GeoPoint::new(37.7749, -122.4194),
radius_meters: 5000.0,
lat_field: None,
lon_field: None,
},
qos: SubscriptionQoS {
sync_mode: SyncMode::LatestOnly,
max_documents: Some(100),
update_rate_ms: Some(1000),
},
};Fields§
§collection: StringCollection to subscribe to
query: QueryQuery filter for documents
qos: SubscriptionQoSQoS settings for this subscription
Implementations§
Source§impl Subscription
impl Subscription
Sourcepub fn all(collection: impl Into<String>) -> Self
pub fn all(collection: impl Into<String>) -> Self
Create a subscription for all documents in a collection
Sourcepub fn with_query(collection: impl Into<String>, query: Query) -> Self
pub fn with_query(collection: impl Into<String>, query: Query) -> Self
Create a subscription with a query
Sourcepub fn with_qos(
collection: impl Into<String>,
query: Query,
qos: SubscriptionQoS,
) -> Self
pub fn with_qos( collection: impl Into<String>, query: Query, qos: SubscriptionQoS, ) -> Self
Create a subscription with query and QoS
Sourcepub fn within_radius(
collection: impl Into<String>,
center: GeoPoint,
radius_meters: f64,
) -> Self
pub fn within_radius( collection: impl Into<String>, center: GeoPoint, radius_meters: f64, ) -> Self
Create a spatial radius subscription
Sourcepub fn within_bounds(
collection: impl Into<String>,
min: GeoPoint,
max: GeoPoint,
) -> Self
pub fn within_bounds( collection: impl Into<String>, min: GeoPoint, max: GeoPoint, ) -> Self
Create a spatial bounds subscription
Sourcepub fn with_sync_mode(self, sync_mode: SyncMode) -> Self
pub fn with_sync_mode(self, sync_mode: SyncMode) -> Self
Set sync mode for this subscription
Sourcepub fn update_query(&mut self, query: Query)
pub fn update_query(&mut self, query: Query)
Update the query for this subscription
Allows modifying the subscription filter without recreating it. Useful for dynamic spatial queries that follow user position.
Sourcepub fn update_qos(&mut self, qos: SubscriptionQoS)
pub fn update_qos(&mut self, qos: SubscriptionQoS)
Update the QoS settings for this subscription
Allows adjusting sync behavior based on runtime conditions (e.g., switching to LatestOnly when bandwidth is constrained).
Sourcepub fn update_sync_mode(&mut self, sync_mode: SyncMode)
pub fn update_sync_mode(&mut self, sync_mode: SyncMode)
Update just the sync mode
Sourcepub fn update_center(&mut self, new_center: GeoPoint)
pub fn update_center(&mut self, new_center: GeoPoint)
Update the spatial center point (for radius queries)
If the current query is a WithinRadius, updates the center point.
Otherwise, this is a no-op.
Sourcepub fn update_radius(&mut self, new_radius: f64)
pub fn update_radius(&mut self, new_radius: f64)
Update the spatial radius (for radius queries)
If the current query is a WithinRadius, updates the radius.
Otherwise, this is a no-op.
Trait Implementations§
Source§impl Clone for Subscription
impl Clone for Subscription
Source§fn clone(&self) -> Subscription
fn clone(&self) -> Subscription
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more