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>) -> Subscription
pub fn all(collection: impl Into<String>) -> Subscription
Create a subscription for all documents in a collection
Sourcepub fn with_query(collection: impl Into<String>, query: Query) -> Subscription
pub fn with_query(collection: impl Into<String>, query: Query) -> Subscription
Create a subscription with a query
Sourcepub fn with_qos(
collection: impl Into<String>,
query: Query,
qos: SubscriptionQoS,
) -> Subscription
pub fn with_qos( collection: impl Into<String>, query: Query, qos: SubscriptionQoS, ) -> Subscription
Create a subscription with query and QoS
Sourcepub fn within_radius(
collection: impl Into<String>,
center: GeoPoint,
radius_meters: f64,
) -> Subscription
pub fn within_radius( collection: impl Into<String>, center: GeoPoint, radius_meters: f64, ) -> Subscription
Create a spatial radius subscription
Sourcepub fn within_bounds(
collection: impl Into<String>,
min: GeoPoint,
max: GeoPoint,
) -> Subscription
pub fn within_bounds( collection: impl Into<String>, min: GeoPoint, max: GeoPoint, ) -> Subscription
Create a spatial bounds subscription
Sourcepub fn with_sync_mode(self, sync_mode: SyncMode) -> Subscription
pub fn with_sync_mode(self, sync_mode: SyncMode) -> Subscription
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 moreAuto Trait Implementations§
impl Freeze for Subscription
impl RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl UnsafeUnpin for Subscription
impl UnwindSafe for Subscription
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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