Add sync settings status page
This commit is contained in:
@@ -8,6 +8,7 @@ mod plugin;
|
||||
mod profile;
|
||||
mod space;
|
||||
mod split;
|
||||
mod sync;
|
||||
mod tab;
|
||||
mod url_text;
|
||||
|
||||
@@ -27,5 +28,8 @@ pub use plugin::{
|
||||
pub use profile::{Profile, ProfileKind};
|
||||
pub use space::{ArchivePolicy, Space};
|
||||
pub use split::{SplitAxis, SplitLayout, SplitPane};
|
||||
pub use sync::{
|
||||
SyncConnectionState, SyncObjectKind, SyncObjectState, SyncObjectStatus, SyncStatus,
|
||||
};
|
||||
pub use tab::{BrowserTab, TabFlags, TabState};
|
||||
pub use url_text::UrlText;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum SyncConnectionState {
|
||||
SignedOut,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum SyncObjectKind {
|
||||
Spaces,
|
||||
Tabs,
|
||||
Profiles,
|
||||
History,
|
||||
PluginSettings,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum SyncObjectState {
|
||||
LocalOnly,
|
||||
PrivacyControlled,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SyncObjectStatus {
|
||||
kind: SyncObjectKind,
|
||||
local_count: usize,
|
||||
state: SyncObjectState,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SyncStatus {
|
||||
connection: SyncConnectionState,
|
||||
pending_objects: usize,
|
||||
failed_objects: usize,
|
||||
objects: Vec<SyncObjectStatus>,
|
||||
}
|
||||
|
||||
impl SyncObjectStatus {
|
||||
#[must_use]
|
||||
pub fn new(kind: SyncObjectKind, local_count: usize, state: SyncObjectState) -> Self {
|
||||
Self { kind, local_count, state }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn kind(&self) -> &SyncObjectKind {
|
||||
&self.kind
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn local_count(&self) -> usize {
|
||||
self.local_count
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn state(&self) -> &SyncObjectState {
|
||||
&self.state
|
||||
}
|
||||
}
|
||||
|
||||
impl SyncStatus {
|
||||
#[must_use]
|
||||
pub fn signed_out(objects: Vec<SyncObjectStatus>) -> Self {
|
||||
Self {
|
||||
connection: SyncConnectionState::SignedOut,
|
||||
pending_objects: 0,
|
||||
failed_objects: 0,
|
||||
objects,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn connection(&self) -> &SyncConnectionState {
|
||||
&self.connection
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn pending_objects(&self) -> usize {
|
||||
self.pending_objects
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn failed_objects(&self) -> usize {
|
||||
self.failed_objects
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn objects(&self) -> &[SyncObjectStatus] {
|
||||
&self.objects
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user