use azure_data_cosmos_driver::models::{MaxItemCountHint, SessionToken};
use azure_data_cosmos_driver::options::OperationOptions;
use crate::feed::ContinuationToken;
#[derive(Clone, Default)]
#[non_exhaustive]
pub struct FeedOptions {
pub max_item_count: Option<MaxItemCountHint>,
pub continuation_token: Option<ContinuationToken>,
}
impl FeedOptions {
pub fn with_max_item_count(mut self, max_item_count: MaxItemCountHint) -> Self {
self.max_item_count = Some(max_item_count);
self
}
pub fn with_continuation_token(mut self, continuation_token: ContinuationToken) -> Self {
self.continuation_token = Some(continuation_token);
self
}
}
#[derive(Clone, Default)]
#[non_exhaustive]
pub struct QueryOptions {
pub operation: OperationOptions,
pub feed: FeedOptions,
pub session_token: Option<SessionToken>,
pub populate_index_metrics: Option<bool>,
pub populate_query_metrics: Option<bool>,
}
impl QueryOptions {
pub fn with_session_token(mut self, session_token: impl Into<SessionToken>) -> Self {
self.session_token = Some(session_token.into());
self
}
pub fn with_operation_options(mut self, operation: OperationOptions) -> Self {
self.operation = operation;
self
}
pub fn with_feed_options(mut self, feed: FeedOptions) -> Self {
self.feed = feed;
self
}
pub fn with_populate_index_metrics(mut self, enable: bool) -> Self {
self.populate_index_metrics = Some(enable);
self
}
pub fn with_populate_query_metrics(mut self, enable: bool) -> Self {
self.populate_query_metrics = Some(enable);
self
}
pub fn with_max_item_count(mut self, max_item_count: MaxItemCountHint) -> Self {
self.feed = self.feed.with_max_item_count(max_item_count);
self
}
pub fn with_continuation_token(mut self, continuation_token: ContinuationToken) -> Self {
self.feed = self.feed.with_continuation_token(continuation_token);
self
}
}