Skip to main content

PortWatcher

Struct PortWatcher 

Source
pub struct PortWatcher { /* private fields */ }
Expand description

A PortWatcher caches listening-socket scans for a short TTL and can be injected with a mock scanner in tests.

Implementations§

Source§

impl PortWatcher

Source

pub fn new() -> Self

A watcher using the real platform scan and the default TTL.

Source

pub fn with_scanner( ttl: Duration, scanner: Box<dyn Fn() -> Vec<(u16, u32, String)> + Send + Sync>, ) -> Self

A watcher with an explicit scan function (used by tests).

Source

pub fn clear(&self)

Clears all cached results, forcing a re-scan on the next call.

Source

pub fn check(&self, ports_to_check: &[u16]) -> Vec<PortStatus>

Returns PortStatus for every requested port that is occupied, re-scanning when any requested port is missing or stale.

Source

pub fn find_blocked(&self, ports_to_check: &[u16]) -> Vec<(u16, u32, String)>

Convenience wrapper returning (port, pid, process_name) triples.

Trait Implementations§

Source§

impl Default for PortWatcher

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.

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