Skip to main content

client_core/
lib.rs

1//! Shared client-side primitives for Cinch CLI and desktop.
2//!
3//! Wire DTOs (`proto::cinch::v1::*`) are generated from the canonical
4//! `proto/cinch/v1/*.proto` files at build time via `prost-build`; see
5//! `build.rs` for the serde attribute injection that keeps wire bytes
6//! byte-equal to the Go relay's `encoding/json` `omitempty` output.
7//!
8//! The optional `specta` feature wires up `specta::Type` derives on wire
9//! DTOs that desktop exposes to the frontend. CLI builds without it.
10
11pub mod auth;
12pub mod auth_session;
13pub mod config;
14pub mod credstore;
15pub mod crypto;
16pub mod http;
17pub mod key_exchange;
18pub mod machine;
19pub mod protocol;
20pub mod recovery;
21pub mod rest;
22pub mod store;
23pub mod sync;
24pub mod version;
25pub mod ws;
26
27/// Generated Rust message types from `proto/cinch/v1/*.proto`.
28///
29/// Wire-compatible with the Go relay's hand-written `protocol/*.go` DTOs:
30/// snake_case JSON tags, `omitempty` semantics preserved via field-level
31/// `skip_serializing_if` predicates injected in `build.rs`.
32#[allow(clippy::all)]
33pub mod proto {
34    pub mod cinch {
35        pub mod v1 {
36            include!(concat!(env!("OUT_DIR"), "/cinch.v1.rs"));
37        }
38    }
39}
40
41/// Helpers used by generated `#[serde(skip_serializing_if = "...")]`
42/// attributes to mirror Go's `encoding/json` `omitempty` semantics on
43/// scalar fields.
44pub mod ser {
45    pub fn is_zero_i32(v: &i32) -> bool {
46        *v == 0
47    }
48    pub fn is_zero_i64(v: &i64) -> bool {
49        *v == 0
50    }
51    pub fn is_false(v: &bool) -> bool {
52        !*v
53    }
54    pub fn is_empty_str(v: &str) -> bool {
55        v.is_empty()
56    }
57    pub fn is_empty_vec<T>(v: &[T]) -> bool {
58        v.is_empty()
59    }
60}