pub struct SyncClient {
api_configurations: Arc<ApiConfigurations>,
sync_handlers: HandlerRegistry<dyn SyncHandler>,
error_handlers: HandlerRegistry<dyn SyncErrorHandler>,
sync_lock: Mutex<()>,
}Expand description
Client for performing sync operations with event support
This client wraps the core sync functionality and provides hooks for registering event handlers that can respond to sync operations.
Fields§
§api_configurations: Arc<ApiConfigurations>§sync_handlers: HandlerRegistry<dyn SyncHandler>§error_handlers: HandlerRegistry<dyn SyncErrorHandler>§sync_lock: Mutex<()>Implementations§
Source§impl SyncClient
impl SyncClient
Sourcepub fn register_sync_handler(&self, handler: Arc<dyn SyncHandler>)
pub fn register_sync_handler(&self, handler: Arc<dyn SyncHandler>)
Register a sync handler for sync operations
Handlers are called in registration order. If any handler returns an error, the sync operation is aborted immediately and subsequent handlers are not called.
Sourcepub fn register_error_handler(&self, handler: Arc<dyn SyncErrorHandler>)
pub fn register_error_handler(&self, handler: Arc<dyn SyncErrorHandler>)
Register an error handler for sync operations
Error handlers are called when any error occurs during sync, including API errors and handler errors. All error handlers are always called regardless of individual failures.
Sourcepub async fn sync(
&self,
request: SyncRequest,
) -> Result<SyncResponseModel, SyncError>
pub async fn sync( &self, request: SyncRequest, ) -> Result<SyncResponseModel, SyncError>
Perform a full sync operation
This method:
- Performs the sync with the Bitwarden API
- On success, dispatches
on_syncwith the sync response to all registered handlers - Dispatches
on_sync_completeto all handlers for post-processing - On error (from API or handlers), notifies all registered error handlers
Handlers receive the raw API models and are responsible for converting to domain types as needed. This allows each handler to decide how to process the data.
If any error occurs, all registered error handlers are notified before the error is returned to the caller.
Sourceasync fn run_handlers(
&self,
response: &SyncResponseModel,
) -> Result<(), SyncError>
async fn run_handlers( &self, response: &SyncResponseModel, ) -> Result<(), SyncError>
Run sync handlers for a completed sync operation
Executes two phases sequentially:
- Calls
SyncHandler::on_syncon all handlers with the response - Calls
SyncHandler::on_sync_completeon all handlers
Stops on first error and returns it immediately.
Sourceasync fn run_error_handlers(&self, error: &SyncError)
async fn run_error_handlers(&self, error: &SyncError)
Run all error handlers for a sync error
All error handlers are called sequentially in registration order.
Sourceasync fn perform_sync(
&self,
input: &SyncRequest,
) -> Result<SyncResponseModel, SyncError>
async fn perform_sync( &self, input: &SyncRequest, ) -> Result<SyncResponseModel, SyncError>
Performs the actual sync operation with the Bitwarden API
Auto Trait Implementations§
impl !Freeze for SyncClient
impl !RefUnwindSafe for SyncClient
impl Send for SyncClient
impl Sync for SyncClient
impl Unpin for SyncClient
impl UnsafeUnpin for SyncClient
impl !UnwindSafe for SyncClient
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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