pub struct QueryOptions<V> {
pub default_value: Option<V>,
pub stale_time: Option<Duration>,
pub gc_time: Option<Duration>,
pub refetch_interval: Option<Duration>,
pub resource_option: Option<ResourceOption>,
}Expand description
Options for a query use_query()
Fields§
§default_value: Option<V>Placeholder value to use while the query is loading for the first time.
stale_time: Option<Duration>The duration that should pass before a query is considered stale.
If the query is stale, it will be refetched.
If no stale_time, the query will never be considered stale.
Stale time is checked when use_query() instance is mounted.
Stale_time can never be greater than cache_time.
Default is 10 seconds.
NOTE: If different stale_time are used for the same key, the MINIMUM time will be used.
gc_time: Option<Duration>The amount of time a query will be cached, once it’s considered stale. If no cache time, the query will never be revoked from cache. cache_time can never be less than stale_time. Default is 5 minutes. NOTE: If different cache times are used for the same key, the MAXIMUM time will be used.
refetch_interval: Option<Duration>If no refetch interval, the query will never refetch.
resource_option: Option<ResourceOption>Determines which type of resource to use.
Implementations§
Source§impl<V> QueryOptions<V>
impl<V> QueryOptions<V>
Sourcepub fn set_default_value(self, default_value: Option<V>) -> Self
pub fn set_default_value(self, default_value: Option<V>) -> Self
Set the default value.
Sourcepub fn set_stale_time(self, stale_time: Option<Duration>) -> Self
pub fn set_stale_time(self, stale_time: Option<Duration>) -> Self
Set the stale_time.
Sourcepub fn set_gc_time(self, gc_time: Option<Duration>) -> Self
pub fn set_gc_time(self, gc_time: Option<Duration>) -> Self
Set the gc time.
Sourcepub fn set_refetch_interval(self, refetch_interval: Option<Duration>) -> Self
pub fn set_refetch_interval(self, refetch_interval: Option<Duration>) -> Self
Set the refetch interval.
Sourcepub fn set_resource_option(
self,
resource_option: Option<ResourceOption>,
) -> Self
pub fn set_resource_option( self, resource_option: Option<ResourceOption>, ) -> Self
Set the resource option.
Sourcepub fn map_value<R>(self, func: impl FnOnce(V) -> R) -> QueryOptions<R>
pub fn map_value<R>(self, func: impl FnOnce(V) -> R) -> QueryOptions<R>
Transform the default value.
Trait Implementations§
Source§impl<V: Clone> Clone for QueryOptions<V>
impl<V: Clone> Clone for QueryOptions<V>
Source§fn clone(&self) -> QueryOptions<V>
fn clone(&self) -> QueryOptions<V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<V: Debug> Debug for QueryOptions<V>
impl<V: Debug> Debug for QueryOptions<V>
Auto Trait Implementations§
impl<V> Freeze for QueryOptions<V>where
V: Freeze,
impl<V> RefUnwindSafe for QueryOptions<V>where
V: RefUnwindSafe,
impl<V> Send for QueryOptions<V>where
V: Send,
impl<V> Sync for QueryOptions<V>where
V: Sync,
impl<V> Unpin for QueryOptions<V>where
V: Unpin,
impl<V> UnwindSafe for QueryOptions<V>where
V: UnwindSafe,
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