pub struct ViewerService {
data_dir: Option<PathBuf>,
tls: Mutex<Option<Arc<ViewerTls>>>,
pub pairing: Pairing,
pub hub: Arc<FeedHub>,
feeds: Arc<Mutex<FeedRegistry>>,
max_per_device: usize,
max_total: usize,
advertised_port: Arc<AtomicU16>,
bound: Mutex<Vec<IpAddr>>,
reservation: Mutex<Option<(u16, Socket)>>,
last_seen_written: Mutex<HashMap<String, i64>>,
}Fields§
§data_dir: Option<PathBuf>Where the certificate is kept; None keeps it in memory only.
tls: Mutex<Option<Arc<ViewerTls>>>§pairing: Pairing§hub: Arc<FeedHub>§feeds: Arc<Mutex<FeedRegistry>>§max_per_device: usize§max_total: usize§advertised_port: Arc<AtomicU16>0 while no viewer listener is bound.
bound: Mutex<Vec<IpAddr>>The addresses viewer listeners are bound on, for the QR’s host.
reservation: Mutex<Option<(u16, Socket)>>The viewer port, held on loopback (bound, never listening) from the first time the listener comes up until exit, so another instance on this host never takes it from the range and the port a device saw stays ours across LAN off/on.
last_seen_written: Mutex<HashMap<String, i64>>When each device’s last_seen_ms was last written.
Implementations§
Source§impl ViewerService
impl ViewerService
Sourcepub fn new(data_dir: Option<PathBuf>, broker: &Broker) -> Arc<Self> ⓘ
pub fn new(data_dir: Option<PathBuf>, broker: &Broker) -> Arc<Self> ⓘ
A viewer whose feeds watch broker.
pub fn with_limits( data_dir: Option<PathBuf>, broker: &Broker, hub: Arc<FeedHub>, max_per_device: usize, max_total: usize, ) -> Arc<Self> ⓘ
Sourcepub fn install_global(&self)
pub fn install_global(&self)
Make this the process’s advertised viewer port (advertised_viewer_port).
Sourcepub fn advertised_port_handle(&self) -> Arc<AtomicU16> ⓘ
pub fn advertised_port_handle(&self) -> Arc<AtomicU16> ⓘ
The handle the fleet feed reads viewer_port from.
pub fn advertised_port(&self) -> Option<u16>
Sourcepub fn tls(&self) -> Result<Arc<ViewerTls>, String>
pub fn tls(&self) -> Result<Arc<ViewerTls>, String>
The certificate, made and kept on first need.
Sourcepub fn reserve_port(
&self,
candidates: impl IntoIterator<Item = u16>,
) -> Option<u16>
pub fn reserve_port( &self, candidates: impl IntoIterator<Item = u16>, ) -> Option<u16>
The viewer port: the one already held, else the first port of
candidates free on loopback, now held. None when none is free.
Sourcepub fn set_bound(&self, addrs: Vec<IpAddr>, port: u16)
pub fn set_bound(&self, addrs: Vec<IpAddr>, port: u16)
Record which addresses viewer listeners are bound on, and advertise the port while there is at least one.
Sourcepub fn pair_host(&self) -> Option<IpAddr>
pub fn pair_host(&self) -> Option<IpAddr>
The IPv4 address the QR names: the primary outbound one when a viewer listener is bound there, else the first bound IPv4 address.
Sourcepub fn open_feed(&self, device_id: &str) -> Result<FeedLease, FeedRefused>
pub fn open_feed(&self, device_id: &str) -> Result<FeedLease, FeedRefused>
Take a place for one more feed of device_id, or say why not.
Sourcepub fn close_device_feeds(&self, device_id: &str) -> usize
pub fn close_device_feeds(&self, device_id: &str) -> usize
Close every open feed of device_id (it was revoked). Returns how many.
Sourcepub fn last_seen_due(&self, device_id: &str, now_ms: i64) -> bool
pub fn last_seen_due(&self, device_id: &str, now_ms: i64) -> bool
Whether device_id’s last_seen_ms is due to be written at now_ms;
records it when it is.
Sourcepub fn forget_device(&self, device_id: &str)
pub fn forget_device(&self, device_id: &str)
Forget a revoked device’s throttle entry.
Auto Trait Implementations§
impl !Freeze for ViewerService
impl !RefUnwindSafe for ViewerService
impl !UnwindSafe for ViewerService
impl Send for ViewerService
impl Sync for ViewerService
impl Unpin for ViewerService
impl UnsafeUnpin for ViewerService
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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