Skip to main content

Ttl

Enum Ttl 

Source
pub enum Ttl {
    None,
    Forever,
    Milliseconds(f64),
    String(String),
}
Expand description

How long a query stays cached after its last use.

Forever and negative durations never expire, None expires immediately. Durations are clamped to 10 minutes when sent to the server.

Variants§

§

None

Expires as soon as nothing uses the query.

§

Forever

Never expires.

§

Milliseconds(f64)

A duration in milliseconds.

§

String(String)

A duration string as JS accepts it: a number followed by s, m, h, d, or y (for example "5m").

Implementations§

Source§

impl Ttl

Source

pub const DEFAULT: &str = "5m"

The default TTL as a string.

Source

pub const DEFAULT_PRELOAD: Ttl = Ttl::None

The TTL JS’s preload uses when it isn’t given one: the query stops being synced as soon as its preload is cleaned up. Ttl::default is the default of views and run.

Source

pub fn seconds(n: f64) -> Ttl

n seconds.

Source

pub fn minutes(n: f64) -> Ttl

n minutes.

Source

pub fn hours(n: f64) -> Ttl

n hours.

Source

pub fn days(n: f64) -> Ttl

n days.

Source

pub fn from_json(v: &Value) -> Option<Ttl>

A TTL as JS holds it: a string or a number.

Source

pub fn to_json(&self) -> Value

The TTL as JS holds it.

Source

pub fn parsed(&self) -> f64

parseTTL: milliseconds, with -1 for never expiring.

Source

pub fn compare(a: &Ttl, b: &Ttl) -> f64

compareTTL: never-expiring sorts last.

Source

pub fn normalized(&self) -> Ttl

normalizeTTL: the shortest equivalent spelling of a number of milliseconds; strings are returned as is.

Source

pub fn clamped(&self) -> f64

clampTTL: milliseconds, at most 10 minutes; never-expiring becomes 10 minutes.

Trait Implementations§

Source§

impl Clone for Ttl

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Ttl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Ttl

Source§

fn default() -> Ttl

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

impl From<&str> for Ttl

Source§

fn from(s: &str) -> Ttl

Converts to this type from the input type.
Source§

impl PartialEq for Ttl

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Ttl

Auto Trait Implementations§

§

impl Forget for Ttl

§

impl Freeze for Ttl

§

impl Move for Ttl

§

impl RefUnwindSafe for Ttl

§

impl Send for Ttl

§

impl Sync for Ttl

§

impl Unpin for Ttl

§

impl UnsafeUnpin for Ttl

§

impl UnwindSafe for Ttl

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.