pub struct SyncClient { /* private fields */ }Expand description
Client for syncing snippets with a remote server.
Wraps a gRPC client with encryption handling for secure sync operations.
Implementations§
Source§impl SyncClient
impl SyncClient
Sourcepub async fn create(settings: SyncSettings) -> SnipResult<Self>
pub async fn create(settings: SyncSettings) -> SnipResult<Self>
Creates a new sync client connected to the server specified in settings.
Sourcepub async fn sync_encrypted(
&mut self,
local_snippets: Vec<Snippet>,
last_sync: i64,
library_id: &str,
) -> SnipResult<SyncResponse>
pub async fn sync_encrypted( &mut self, local_snippets: Vec<Snippet>, last_sync: i64, library_id: &str, ) -> SnipResult<SyncResponse>
Encrypts local snippets, sends them to the server, and decrypts the response.
Snippets that fail encryption/decryption are counted as skipped. Handles server-side pagination by fetching all pages before returning.
Sourcepub async fn health_check(&mut self) -> SnipResult<bool>
pub async fn health_check(&mut self) -> SnipResult<bool>
Checks server health and returns true if the server is reachable.
Sourcepub async fn register(server_url: String) -> SnipResult<(String, String)>
pub async fn register(server_url: String) -> SnipResult<(String, String)>
Registers a new device with the server and returns the API key and device ID.
Sourcepub async fn list_libraries(&mut self) -> SnipResult<Vec<Library>>
pub async fn list_libraries(&mut self) -> SnipResult<Vec<Library>>
Lists all libraries on the sync server.
Sourcepub async fn create_library(&mut self, name: &str) -> SnipResult<Library>
pub async fn create_library(&mut self, name: &str) -> SnipResult<Library>
Creates a new library on the sync server.
Sourcepub async fn list_premade_libraries(
&mut self,
) -> SnipResult<Vec<PremadeLibrary>>
pub async fn list_premade_libraries( &mut self, ) -> SnipResult<Vec<PremadeLibrary>>
Lists all premade libraries available on the server.
Sourcepub async fn get_premade_library(
&mut self,
filename: &str,
) -> SnipResult<String>
pub async fn get_premade_library( &mut self, filename: &str, ) -> SnipResult<String>
Downloads a premade library’s content from the server.
Sourcepub async fn search_premade_libraries(
&mut self,
query: &str,
) -> SnipResult<Vec<PremadeLibrary>>
pub async fn search_premade_libraries( &mut self, query: &str, ) -> SnipResult<Vec<PremadeLibrary>>
Searches premade libraries on the server by query string.
Auto Trait Implementations§
impl !Freeze for SyncClient
impl !RefUnwindSafe for SyncClient
impl !UnwindSafe for SyncClient
impl Send for SyncClient
impl Sync for SyncClient
impl Unpin for SyncClient
impl UnsafeUnpin for SyncClient
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request