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 ws;
25
26/// Generated Rust message types from `proto/cinch/v1/*.proto`.
27///
28/// Wire-compatible with the Go relay's hand-written `protocol/*.go` DTOs:
29/// snake_case JSON tags, `omitempty` semantics preserved via field-level
30/// `skip_serializing_if` predicates injected in `build.rs`.
31#[allow(clippy::all)]
32pub mod proto {
33 pub mod cinch {
34 pub mod v1 {
35 include!(concat!(env!("OUT_DIR"), "/cinch.v1.rs"));
36 }
37 }
38}
39
40/// Helpers used by generated `#[serde(skip_serializing_if = "...")]`
41/// attributes to mirror Go's `encoding/json` `omitempty` semantics on
42/// scalar fields.
43pub mod ser {
44 pub fn is_zero_i32(v: &i32) -> bool {
45 *v == 0
46 }
47 pub fn is_zero_i64(v: &i64) -> bool {
48 *v == 0
49 }
50 pub fn is_false(v: &bool) -> bool {
51 !*v
52 }
53 pub fn is_empty_str(v: &str) -> bool {
54 v.is_empty()
55 }
56 pub fn is_empty_vec<T>(v: &[T]) -> bool {
57 v.is_empty()
58 }
59}