Skip to main content

RestClient

Struct RestClient 

Source
pub struct RestClient { /* private fields */ }

Implementations§

Source§

impl RestClient

Source

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.

Source

pub async fn push_clip_json( &self, req: &PushRequest, ) -> Result<PushResponse, HttpError>

POST /clips with JSON body — text and encrypted-binary path.

Source

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.

Source

pub async fn pull_clipboard(&self) -> Result<PullResponse, HttpError>

POST /pull — request the local Mac clipboard via WS round-trip.

Source

pub async fn get_latest_clip(&self, source: &str) -> Result<Clip, HttpError>

GET /clips/latest?source=... — most recent clip matching source.

Source

pub async fn get_clip_media(&self, clip_id: &str) -> Result<Vec<u8>, HttpError>

GET /clips/{id}/media — raw image bytes for image clips.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub async fn delete_clip(&self, clip_id: &str) -> Result<(), HttpError>

DELETE /clips/{id} — remove a clip. 404 is treated as success.

Source

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.

Source

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

Source§

fn clone(&self) -> RestClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RestClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more