Skip to main content

TabRegistry

Struct TabRegistry 

Source
pub struct TabRegistry {
    tabs: BTreeMap<u16, Tab>,
    current: HashMap<SessionSlot, u16>,
    retired: HashSet<u16>,
    unresolved: HashSet<u16>,
    closed: HashSet<u16>,
}
Expand description

The profile’s tabs, keyed by the host’s own tab number. The registry never mints one: the host’s numbers are what frames, mouse input and TabClosed already carry, and a second counter would drift from them.

Fields§

§tabs: BTreeMap<u16, Tab>§current: HashMap<SessionSlot, u16>§retired: HashSet<u16>

Every number this registry has ever taken. A retired number is never handed out again, so a hand-off written against it can never come to mean another tab.

§unresolved: HashSet<u16>

Tabs whose page a listing could not name. Their pages are not orphans: the prune closes nothing while one is unresolved, or a live document would be closed because its row could not be paired.

§closed: HashSet<u16>

Numbers the host has reported ended, including ones no row ever took. A birth for one of these is not waiting for a page: a popup the host gave up closed before its page existed, and a birth kept for it would be re-deferred for ever - a driver recovery on every pass.

Implementations§

Source§

impl TabRegistry

Source

pub fn adopt( &mut self, number: u16, owner: SessionSlot, target: &str, title: &str, url: &str, ) -> Result<u16, String>

Take the host’s tab number for owner. A number the registry has seen before is a refusal: the host never reuses one, so a duplicate is a bug in the pairing, not a tab to overwrite.

Source

pub fn create_under( &mut self, opener: u16, number: u16, target: &str, title: &str, url: &str, ) -> Result<u16, String>

A tab the page opened: it belongs to whoever owns opener.

Source

pub fn close(&mut self, tab: u16) -> Option<SessionSlot>

Remove one tab and answer the session that owned it. The unresolved flag goes even for a row already gone: a close landing between a listing and its mark must not leave the flag on a retired number.

A popup closing hands its session back to the opener. An OAuth popup closes itself the moment it is done, and a session left with no tab would open a fresh blank page on its next call instead of the page the sign-in started from.

Source

pub fn mark_unresolved(&mut self, tab: u16)

Remember that a listing could not name this tab’s page, so no page is pruned as an orphan while the row is unresolved. Only an open row is marked: a number with no row has no page to protect.

Source

pub fn unresolved_tabs(&self) -> Vec<u16>

The tabs whose page a listing could not name.

Source

pub fn was_closed(&self, tab: u16) -> bool

Whether the host has reported this number ended. A birth for one is answered rather than kept: nothing will ever list its page.

Source

pub fn close_owned( &mut self, session: &SessionSlot, tab: u16, ) -> Result<Option<SessionSlot>, String>

Source

pub fn current(&self, session: &SessionSlot) -> Option<u16>

Source

pub fn forget_current(&mut self, session: &SessionSlot)

Forget a session’s current tab without closing it: a replacement keeps the slot but inherits none of the occupant’s place.

Source

pub fn select(&mut self, session: &SessionSlot, tab: u16) -> Result<(), String>

Source

pub fn target(&self, tab: u16) -> Option<&str>

Source

pub fn number_of(&self, target: &str) -> Option<u16>

The tab a page target names, or None when that page is gone.

The identity an open resolves: a tab number survives a host replacement in name only, and the successor’s first tab takes number 1 again.

Source

pub fn listing(&self) -> String

The tabs as one line, for a refusal that names what is open now.

Source

pub fn title_url(&self, tab: u16) -> Option<(&str, &str)>

A tab’s title and url, for the listing the tools answer with.

Source

pub fn owned_target( &self, session: &SessionSlot, target: &str, ) -> Result<u16, String>

The tab whose page is target, if this session owns it. The page id is the tab’s address: the host’s number restarts with every host, so an id no row carries is refused rather than resolved to whatever holds that number today.

Source

pub fn owner(&self, tab: u16) -> Option<&SessionSlot>

Source

pub fn other_owners(&self, except: &SessionSlot) -> Vec<(SessionSlot, Duration)>

The sessions other than except holding a tab, each with how long it has held its oldest one: what a host end must not take with it.

Source

pub fn other_owners_at( &self, except: &SessionSlot, now: Instant, ) -> Vec<(SessionSlot, Duration)>

Self::other_owners against a clock the caller owns, so a test needs no instant older than the machine’s boot.

Source

pub fn mark_busy(&mut self, tab: u16, busy: bool)

Source

pub fn update(&mut self, tab: u16, title: &str, url: &str) -> bool

Replace a row’s title and url, answering whether either changed.

Source

pub(crate) fn owned( &self, session: &SessionSlot, tab: u16, ) -> Result<&Tab, String>

Source

pub fn rows( &self, held: &HashSet<u16>, controlled: &HashSet<u16>, dialogs: &HashMap<u16, BrowserTabDialog>, ) -> Vec<BrowserTabRow>

The rows the strip draws. A held tab outranks a busy one: the person is being asked about it, which is the fact worth seeing. A tab a person is driving is in use, like one a call is driving: the spec’s in-use is either.

Source

pub fn is_empty(&self) -> bool

Source

pub fn numbers(&self) -> Vec<u16>

Source

pub fn popup_age(&self, now: Instant) -> Option<Duration>

The age of the youngest popup tab, or None when no popup is open. A popup’s target hangs a fresh driver’s connect whether or not its document has started, so the host is kept while one is inside its window; past it, the popup is the wedge rather than a sign-in in progress. is_popup, not opener: an opener that closes first hands its children None, and the popup is still a popup.

Trait Implementations§

Source§

impl Default for TabRegistry

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.

§

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.

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 = !

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

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