pub struct ScanSession { /* private fields */ }Expand description
A handle to an active network scan: what it has found, what it is doing, and the means to stop it.
Returned by discover and
scan alongside the
ScanTask that resolves to the final report.
This describes the present moment and keeps no history.
Dropping it stops nothing. Dropping the task stops the scan; see
ScanTask.
use zond_engine::ScanEvent;
while let Some(event) = session.events().recv().await {
if let ScanEvent::HostUpdated(ip) = event
&& let Some(host) = session.hosts().get(&ip)
{
println!("{host}");
}
}Implementations§
Source§impl ScanSession
impl ScanSession
Sourcepub fn hosts(&self) -> &HostStore
pub fn hosts(&self) -> &HostStore
What the scan has found so far.
Once the scan is over this holds the hosts its report lists. While it
runs it can hold more: a port scan with no liveness pass files a record
at every address it asks and drops the silent ones when its ports are
done, so an event naming such an address may find no host. See
ScanPhase::silent.
Sourcepub fn events(&mut self) -> &mut ScanEvents
pub fn events(&mut self) -> &mut ScanEvents
The live event stream.
Bounded: a consumer that reads it slowly, or not at all, loses the
oldest events. See ScanEvents.
Sourcepub fn handle(&self) -> &ScanHandle
pub fn handle(&self) -> &ScanHandle
The control handle, which is how a scan is stopped early.
Sourcepub fn progress(&self) -> &Progress
pub fn progress(&self) -> &Progress
How far the scan has got through its plan.
Cloneable, so a caller rendering a scan elsewhere can take a copy. See
Progress.
Sourcepub fn into_parts(self) -> (HostStore, ScanEvents, ScanHandle, Progress)
pub fn into_parts(self) -> (HostStore, ScanEvents, ScanHandle, Progress)
Takes the session apart, for a caller that wants to watch the events from one task and read the hosts from another.
HostStore, ScanHandle and Progress are cloneable, so this is
only needed to move the event stream, of which there is one.
Source§impl ScanSession
impl ScanSession
Sourcepub fn new() -> (Self, ScanContext)
pub fn new() -> (Self, ScanContext)
A session and the context the strategies behind it write into, with
nothing excluded, nothing resumed, no address numbering, and a walk
order of its own; see SessionBuilder::ordering.
discover and scan
build their own session. A caller orchestrating their own scan calls
this first, since every strategy in strategy
is constructed with a ScanContext.
builder takes further settings.
Sourcepub fn builder() -> SessionBuilder
pub fn builder() -> SessionBuilder
A session with exclusions, a resume point or an address numbering.
See SessionBuilder.
Auto Trait Implementations§
impl !RefUnwindSafe for ScanSession
impl !UnwindSafe for ScanSession
impl Freeze for ScanSession
impl Send for ScanSession
impl Sync for ScanSession
impl Unpin for ScanSession
impl UnsafeUnpin for ScanSession
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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