pub struct Check { /* private fields */ }Expand description
Result of a single network connectivity check.
Contains all information about a check attempt including:
- When it was performed
- What type of check it was
- Whether it succeeded
- Measured latency (if successful)
- Target address
Implementations§
Source§impl Check
impl Check
Sourcepub fn get_hash(&self) -> Hash
pub fn get_hash(&self) -> Hash
Generates a cryptographic hash of the Check data.
Uses blake3 for consistent hashing across Rust versions and platforms. The hash remains stable as long as the check’s contents don’t change, making it suitable for persistent identification of checks.
§Implementation Details
- Uses bincode for serialization of check data
- Uses blake3 for cryptographic hashing
- Produces a 32-byte (256-bit) hash
§Panics
May panic if serialization fails, which can happen in extreme cases:
- System is out of memory
- System is in a severely degraded state
Normal Check data will always serialize successfully.
Sourcepub fn new(
time: impl Into<DateTime<Utc>>,
flags: impl Into<FlagSet<CheckFlag>>,
latency: Option<u16>,
target: IpAddr,
) -> Self
pub fn new( time: impl Into<DateTime<Utc>>, flags: impl Into<FlagSet<CheckFlag>>, latency: Option<u16>, target: IpAddr, ) -> Self
Creates a new check result with the specified properties.
This does not execute a check and then store the information about that check in this datastructure, it simply allows the creation of arbitrary check results
§Arguments
time- When the check was performedflags- Initial status flagslatency- Measured latency (if successful)target- Target IP address
§Panics
Panics if timestamp is before UNIX_EPOCH.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns whether this check was successful.
A check is considered successful if it has the Success flag and no unexpected flag combinations.
Sourcepub fn latency(&self) -> Option<u16>
pub fn latency(&self) -> Option<u16>
Returns the measured latency if check was successful.
Returns None if:
- Check failed
- Check succeeded but no latency was recorded
Sourcepub fn timestamp_parsed(&self) -> DateTime<Local>
pub fn timestamp_parsed(&self) -> DateTime<Local>
Returns the timestamp of this Check as SystemTime.
The Check structure stores just seconds since UNIX_EPOCH, which is agnostic of
timezones. The seconds since the UNIX_EPOCH (1970-01-01 00:00) are converted to a timestamp
in UTC, and just for the formatting the timestamp is converted to the timezone of the user.
Sourcepub fn flags_mut(&mut self) -> &mut FlagSet<CheckFlag>
pub fn flags_mut(&mut self) -> &mut FlagSet<CheckFlag>
Returns a mutable reference to the flags of this Check.
Sourcepub fn calc_type(&self) -> Result<CheckType, StoreError>
pub fn calc_type(&self) -> Result<CheckType, StoreError>
Determines CheckType from this checks flags.
Examines the type and protocol flags to determine the specific kind of check that was performed.
Returns CheckType::Unknown if flags indicate an invalid combination.
Sourcepub fn set_target(&mut self, target: IpAddr)
pub fn set_target(&mut self, target: IpAddr)
Updates the target IP address of this check.
Trait Implementations§
impl Copy for Check
Source§impl DeepSizeOf for Check
impl DeepSizeOf for Check
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§fn deep_size_of(&self) -> usize
fn deep_size_of(&self) -> usize
Source§impl<'de> Deserialize<'de> for Check
impl<'de> Deserialize<'de> for Check
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Check
Source§impl Ord for Check
impl Ord for Check
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Check
impl PartialOrd for Check
impl StructuralPartialEq for Check
Auto Trait Implementations§
impl Freeze for Check
impl RefUnwindSafe for Check
impl Send for Check
impl Sync for Check
impl Unpin for Check
impl UnsafeUnpin for Check
impl UnwindSafe for Check
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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