[][src]Enum extrahop::QueryTime

pub enum QueryTime {
    Milliseconds(i64),
    Unitized(String),
}

Represents an absolute or relative time sent to an ExtraHop appliance as part of a query.

Usage

QueryTime instances should generally be constructed using the conversion traits, rather than directly.

let _time: QueryTime = (-30000 as i64).into();
let _other: QueryTime = "-30m".into();

Variants

Milliseconds(i64)

A number of milliseconds. Positive values are assessed since the Unix epoch, while non-positive values (including 0) are assessed relative to the appliance's "now" value.

Unitized(String)

A possibly-unitized amount of time, expressed as a string.

Methods

impl QueryTime[src]

pub fn is_relative(&self) -> bool[src]

Returns true if the query time is relative to the appliance's "now".

Examples

assert!(QueryTime::from("-30m").is_relative());
assert!(QueryTime::from(0).is_relative());

pub fn is_absolute(&self) -> bool[src]

Returns true if the query time is measured from the Unix epoch.

pub fn validate(self) -> Result<Self>[src]

Check that a query time specification will be accepted by the appliance, returning the unmodified query time if so, and otherwise returning an error.

This function internally calls QueryTime::is_valid.

pub fn is_valid(&self) -> bool[src]

Check that a query time specification will be accepted by the appliance.

Caution

This method attempts to reimplement the appliance's own format checking for unitized time strings, so it is possible that future firmware will accept values not accepted by this method.

Validation

  • Numeric time values are allowed without further inspection
  • Relative unitized time values must adhere to this expression: ^-\d+(?:ms|s|m|h|d|y)?$
  • Absolute unitized time values must be composed of only digits

Examples

// Valid
assert!(QueryTime::from(0).is_valid());
assert!(QueryTime::from(-25000).is_valid());
assert!(QueryTime::from("-1m").is_valid());
assert!(QueryTime::from("-50").is_valid());
assert!(QueryTime::from("-10ms").is_valid());
assert!(QueryTime::from("0").is_valid());

// Invalid
assert!(!QueryTime::from("10m").is_valid());
assert!(!QueryTime::from("1-0").is_valid());

Trait Implementations

impl Clone for QueryTime[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for QueryTime[src]

impl From<i64> for QueryTime[src]

impl<'a> From<&'a str> for QueryTime[src]

impl From<String> for QueryTime[src]

Convert a string to a query time. This may convert the query time to a number if doing so would not change readability in the serialized form.

impl Debug for QueryTime[src]

impl FromStr for QueryTime[src]

type Err = Error

The associated error which can be returned from parsing.

impl Serialize for QueryTime[src]

impl<'de> Deserialize<'de> for QueryTime[src]

Auto Trait Implementations

impl Send for QueryTime

impl Sync for QueryTime

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T