[−][src]Enum extrahop::QueryTime
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(&self) -> 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.
fn from_str(v: &str) -> Result<Self>
[src]
impl Serialize for QueryTime
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for QueryTime
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,