pub struct QueryOptions<V> {
    pub default_value: Option<V>,
    pub stale_time: Option<Duration>,
    pub cache_time: Option<Duration>,
    pub refetch_interval: Option<Duration>,
    pub resource_option: ResourceOption,
}
Expand description

Options for a query crate::use_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 QueryState::read is used. Stale time can never be greater than cache_time. Default is 0 milliseconds. NOTE: If different stale times are used for the same key, the minimum time for the currently ACTIVE query will be used.

§cache_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 minimum time will be used.

§refetch_interval: Option<Duration>

If no refetch interval, the query will never refetch.

§resource_option: ResourceOption

Determines which type of resource to use.

Implementations§

source§

impl<V> QueryOptions<V>

source

pub fn empty() -> Self

Empty options.

source

pub fn stale_time(stale_time: Duration) -> Self

QueryOption with custom stale_time.

source

pub fn refetch_interval(refetch_interval: Duration) -> Self

QueryOption with custom refetch_interval.

Trait Implementations§

source§

impl<V: Clone> Clone for QueryOptions<V>

source§

fn clone(&self) -> QueryOptions<V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V> Default for QueryOptions<V>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more