Skip to main content

ConnectivityMonitor

Struct ConnectivityMonitor 

Source
pub struct ConnectivityMonitor {
    server_url: Arc<RwLock<Option<String>>>,
    http_client: Arc<HttpClient>,
    reporter: ConnectivityReporter,
    is_monitoring: Arc<AtomicBool>,
}
Expand description

Connectivity monitor for tracking server reachability.

Reachability is driven primarily by real repository traffic via the shared ConnectivityReporter. The monitor itself only runs an offline recovery probe (see start_monitoring) and serves the connectivity Tauri commands.

Fields§

§server_url: Arc<RwLock<Option<String>>>§http_client: Arc<HttpClient>§reporter: ConnectivityReporter§is_monitoring: Arc<AtomicBool>

Implementations§

Source§

impl ConnectivityMonitor

Source

pub fn new(http_client: HttpClient) -> Self

Create a new connectivity monitor

Source

pub fn set_app_handle(&mut self, app_handle: AppHandle)

Set the Tauri app handle for event emission. Must be called before the reporter is shared with the repository.

Source

pub fn reporter(&self) -> ConnectivityReporter

Get a cheap, cloneable reporter so the repository can feed server outcomes into the same reachability state the UI observes.

Source

pub async fn set_server_url(&self, url: String)

Update the server URL

Source

pub async fn get_status(&self) -> ConnectivityStatus

Get current connectivity status

Source

pub async fn check_reachability(&self) -> bool

Deliberately probe the server’s reachability (manual check / recovery probe). The result is applied immediately (no debounce) since this is an explicit test.

Source

pub async fn mark_reachable(&self)

Mark server as reachable (called after successful API call / login)

Source

pub async fn mark_unreachable(&self, error: Option<String>)

Mark server as unreachable directly.

Used by deliberate signals (e.g. a failed login/connect) where the caller knows the server is unreachable now. Repository traffic should prefer reporter().report_network_failure() so the debounce applies.

Source

pub async fn start_monitoring(&self)

Start the offline recovery probe.

While online, reachability is kept fresh by real traffic, so the probe idles. While offline, it polls /System/Info/Public every RETRY_CHECK_INTERVAL_MS to detect the server returning even when no user traffic is flowing.

Source

pub fn stop_monitoring(&self)

Stop monitoring connectivity

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more