pub struct Writer { /* private fields */ }Expand description
Long-lived WS-driven sync writer. One per machine, coordinated by the
~/.cinch/sync.lock advisory lockfile.
Implementations§
Source§impl Writer
impl Writer
Sourcepub async fn start(
store: Arc<Store>,
client: Arc<RestClient>,
ws_cfg: WsConfig,
lock_path: PathBuf,
kind: LockKind,
on_new_clip: Option<OnNewClipCallback>,
on_connected: Option<OnConnectedCallback>,
) -> Result<Option<Self>>
pub async fn start( store: Arc<Store>, client: Arc<RestClient>, ws_cfg: WsConfig, lock_path: PathBuf, kind: LockKind, on_new_clip: Option<OnNewClipCallback>, on_connected: Option<OnConnectedCallback>, ) -> Result<Option<Self>>
Try to start a writer. Returns Ok(None) if another writer already
holds the lock.
The caller must supply a WsConfig (relay URL + bearer token +
optional 32-byte AES key). The same RestClient is used for the
initial REST backfill.
Use Writer::with_on_connected on the returned value to register a
reconnect callback before the first WsStatus::Connected event fires.
Sourcepub fn with_on_connected(self, cb: OnConnectedCallback) -> Self
pub fn with_on_connected(self, cb: OnConnectedCallback) -> Self
Register (or replace) the callback that fires on every
WsStatus::Connected event.
This is a builder-style setter intended for use with a Writer that
was constructed without a connected callback. Note that if the writer
background task has already started, changing this field has no effect
on the running task — use the on_connected parameter of
Writer::start to supply the callback at construction time.