pub struct RestClient { /* private fields */ }Implementations§
Source§impl RestClient
impl RestClient
Sourcepub fn new(
relay_url: impl Into<String>,
token: impl Into<String>,
) -> Result<Self, HttpError>
pub fn new( relay_url: impl Into<String>, token: impl Into<String>, ) -> Result<Self, HttpError>
Construct a new client. relay_url is trimmed of any trailing slash.
Sourcepub async fn push_clip_json(
&self,
req: &PushRequest,
) -> Result<PushResponse, HttpError>
pub async fn push_clip_json( &self, req: &PushRequest, ) -> Result<PushResponse, HttpError>
POST /clips with JSON body — text and encrypted-binary path.
Sourcepub async fn push_clip_binary(
&self,
data: Vec<u8>,
content_type: &str,
source: &str,
label: Option<&str>,
target_device_id: Option<&str>,
) -> Result<PushResponse, HttpError>
pub async fn push_clip_binary( &self, data: Vec<u8>, content_type: &str, source: &str, label: Option<&str>, target_device_id: Option<&str>, ) -> Result<PushResponse, HttpError>
POST /clips/binary — multipart form for unencrypted binary.
data is the raw file bytes; metadata fields are sent as form fields.
Sourcepub async fn pull_clipboard(&self) -> Result<PullResponse, HttpError>
pub async fn pull_clipboard(&self) -> Result<PullResponse, HttpError>
POST /pull — request the local Mac clipboard via WS round-trip.
Sourcepub async fn get_latest_clip(&self, source: &str) -> Result<Clip, HttpError>
pub async fn get_latest_clip(&self, source: &str) -> Result<Clip, HttpError>
GET /clips/latest?source=... — most recent clip matching source.
Sourcepub async fn get_clip_media(&self, clip_id: &str) -> Result<Vec<u8>, HttpError>
pub async fn get_clip_media(&self, clip_id: &str) -> Result<Vec<u8>, HttpError>
GET /clips/{id}/media — raw image bytes for image clips.
Sourcepub async fn start_device_code(
&self,
relay_url: &str,
hostname: &str,
machine_id: &str,
user_hint: Option<&str>,
) -> Result<DeviceCodeResponse, HttpError>
pub async fn start_device_code( &self, relay_url: &str, hostname: &str, machine_id: &str, user_hint: Option<&str>, ) -> Result<DeviceCodeResponse, HttpError>
POST /auth/device-code — start the device-code flow. The relay
returns a verification_uri for the user to open in a browser.
machine_id is opaque (empty string disables relay-side dedup).
Sourcepub async fn poll_device_code(
&self,
relay_url: &str,
device_code: &str,
) -> Result<DeviceCodePollResponse, HttpError>
pub async fn poll_device_code( &self, relay_url: &str, device_code: &str, ) -> Result<DeviceCodePollResponse, HttpError>
GET /auth/device-code/poll?code=... — single poll. Caller drives
the loop and respects interval from the start response.
Sourcepub async fn complete_device_code(
&self,
user_code: &str,
) -> Result<(), HttpError>
pub async fn complete_device_code( &self, user_code: &str, ) -> Result<(), HttpError>
POST /auth/device-code/complete — approve a pending device-code
login from an already-authenticated local device.
Sourcepub async fn deny_device_code(&self, user_code: &str) -> Result<(), HttpError>
pub async fn deny_device_code(&self, user_code: &str) -> Result<(), HttpError>
POST /cinch.v1.AuthService/DeviceCodeDeny (Connect-RPC unary, JSON encoding)
— reject a pending device-code login from this already-signed-in device.
Sourcepub async fn probe_relay(&self, relay_url: &str) -> Result<(), HttpError>
pub async fn probe_relay(&self, relay_url: &str) -> Result<(), HttpError>
GET /health — liveness probe used by the wizard before issuing a
device code, so URL typos surface as a clean error before the user
is sent to a browser.
Sourcepub async fn post_key_bundle(
&self,
target_device_id: &str,
ephemeral_public_key: &str,
encrypted_bundle: &str,
) -> Result<(), HttpError>
pub async fn post_key_bundle( &self, target_device_id: &str, ephemeral_public_key: &str, encrypted_bundle: &str, ) -> Result<(), HttpError>
POST /auth/key-bundle — publish an encrypted user-key bundle
for target_device_id. Called by any device that holds the
user’s master key when the relay broadcasts a
key_exchange_requested event for a freshly-paired peer.
ephemeral_public_key and encrypted_bundle are both
base64url-encoded. Bearer-authenticated.
Sourcepub async fn register_device_public_key(
&self,
public_key: &str,
fingerprint: &str,
) -> Result<(), HttpError>
pub async fn register_device_public_key( &self, public_key: &str, fingerprint: &str, ) -> Result<(), HttpError>
POST /auth/device/public-key — register the X25519 public key
for the calling device so the relay can include it in
ListPendingKeyExchanges sweeps and broadcast
key_exchange_requested events for it. Called once after the
OAuth-only login flow finishes installing local credentials.
Bearer-authenticated.
Sourcepub async fn retry_key_bundle(&self) -> Result<(), HttpError>
pub async fn retry_key_bundle(&self) -> Result<(), HttpError>
POST /auth/key-bundle/retry — ask the relay to re-broadcast
key_exchange_requested for the calling device. Used when the
initial key handoff missed (no key-bearer was online at login
time). Bearer-authenticated.
Sourcepub async fn revoke_device(&self, device_id: &str) -> Result<(), HttpError>
pub async fn revoke_device(&self, device_id: &str) -> Result<(), HttpError>
POST /auth/device/revoke — revoke the active device server-side.
Best-effort: callers should still wipe local credentials regardless
of relay reachability.
Sourcepub async fn set_device_nickname(
&self,
device_id: &str,
nickname: &str,
) -> Result<(), HttpError>
pub async fn set_device_nickname( &self, device_id: &str, nickname: &str, ) -> Result<(), HttpError>
PUT /devices/{device_id}/nickname — set or clear a human-readable
nickname for a paired device. An empty string clears the nickname.
Task 5.9 uses this path; the desktop set_device_nickname command
delegates here rather than calling reqwest directly.
Sourcepub async fn set_remote_retention(&self, days: i32) -> Result<(), HttpError>
pub async fn set_remote_retention(&self, days: i32) -> Result<(), HttpError>
PUT /devices/self/retention — set this device’s remote retention
(in days). The relay only exposes a self-targeted endpoint; per-device
retention writes are not supported over REST.
Sourcepub async fn get_key_bundle(&self) -> Result<KeyBundleResponse, HttpError>
pub async fn get_key_bundle(&self) -> Result<KeyBundleResponse, HttpError>
GET /auth/key-bundle — fetch the encrypted user-key bundle the
desktop publishes after a pair. Bearer-authenticated.
Always returns 200; an absent bundle is signalled by empty
ephemeral_public_key/encrypted_bundle plus a non-empty
pending_since RFC3339 timestamp, so callers can poll without
distinguishing “not yet” from “device unknown” via status code.
Sourcepub async fn list_clips_since(
&self,
since: Option<DateTime<Utc>>,
limit: u32,
) -> Result<Vec<Clip>, HttpError>
pub async fn list_clips_since( &self, since: Option<DateTime<Utc>>, limit: u32, ) -> Result<Vec<Clip>, HttpError>
GET /clips[?since=<rfc3339>][&limit=<n>] — list clips, optionally filtered to those
newer than since. Returns oldest-first when since is provided.
limit caps the number of results (relay maximum is 100).
Sourcepub async fn list_clips(
&self,
filter: ListClipsFilter,
) -> Result<Vec<Clip>, HttpError>
pub async fn list_clips( &self, filter: ListClipsFilter, ) -> Result<Vec<Clip>, HttpError>
GET /clips?... — list clips with the given filter, newest-first.
Limit is clamped server-side; the client clamps to 200 to match the relay cap.
Sourcepub async fn get_clip_by_id(&self, clip_id: &str) -> Result<Clip, HttpError>
pub async fn get_clip_by_id(&self, clip_id: &str) -> Result<Clip, HttpError>
GET /clips?clip_id=<id>&limit=1 — fetch one clip by ID.
Sourcepub async fn get_latest_clip_excluding(
&self,
exclude_source: &str,
) -> Result<Clip, HttpError>
pub async fn get_latest_clip_excluding( &self, exclude_source: &str, ) -> Result<Clip, HttpError>
GET /clips/latest?exclude_source=<key> — latest clip whose source != exclude_source.
Sourcepub async fn delete_clip(&self, clip_id: &str) -> Result<(), HttpError>
pub async fn delete_clip(&self, clip_id: &str) -> Result<(), HttpError>
DELETE /clips/{id} — remove a clip. 404 is treated as success.
Sourcepub async fn set_clip_pin(
&self,
clip_id: &str,
is_pinned: bool,
pin_note: Option<&str>,
) -> Result<(), HttpError>
pub async fn set_clip_pin( &self, clip_id: &str, is_pinned: bool, pin_note: Option<&str>, ) -> Result<(), HttpError>
POST /clips/{id}/pin — set or clear pin state. Best-effort: 404 treated as success.
Sourcepub async fn list_devices(&self) -> Result<Vec<DeviceInfo>, HttpError>
pub async fn list_devices(&self) -> Result<Vec<DeviceInfo>, HttpError>
GET /devices — list of paired devices for the current user.
Trait Implementations§
Source§impl Clone for RestClient
impl Clone for RestClient
Source§fn clone(&self) -> RestClient
fn clone(&self) -> RestClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more