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