1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! # PSICOSE-1B
//!
//! A `no_std`, heapless **framework** for reliable byte links: wire protocol,
//! pump, windowing, and **P2P sessions**. You compose the layers; nothing
//! allocates. **Zero crate dependencies** — `use psicose::…` is only PSICOSE.
//!
//! P2P is **not** a separate crate. [`Node`], [`PeerId`], [`PeerTable`],
//! [`PeerLink`], hello negotiation, and fragmentation live in this package
//! on top of the same 4-byte frame. Examples call into this motor — they
//! do not invent an external P2P and pass connections in.
//!
//! ## Framework layers
//!
//! ```text
//! exemplos / application / boards/*
//! │
//! ▼
//! psicose::Node ← motor entry
//! ├─ PeerLink / PeerTable / hello
//! ├─ Fragmenter / Defragmenter
//! ▼
//! LinkFace / Wire::copy / Pump / WindowedPump
//! │ DATA 1 byte/frame + CRC-8 + ACK
//! ▼
//! ByteTransport (you implement on UART, or Wire harness)
//! ```
//!
//! | Layer | Entry points |
//! | --- | --- |
//! | Wire frame / CRC / SEQ | [`Frame`], [`crc8`] |
//! | Stop-and-wait / window | [`Pump`], [`WindowedPump`], [`Wire::copy`] |
//! | Hardware demux | [`LinkFace`] |
//! | P2P session + peers | [`Node`], [`PeerLink`], [`establish`] |
//!
//! ## Non-negotiable properties
//!
//! - **`#![no_std]`, `#![forbid(unsafe_code)]`, zero dependencies.**
//! No heap, no `Vec`, no third-party crates in the dependency graph.
//! - **Constant memory regardless of transfer size.**
//! - **The wire frame is fixed at [`protocol::FRAME_LEN`] = 4 bytes:**
//! `TYPE(1) | SEQ(1) | DATA(1) | CRC(1)`.
//! - **Reliability is the protocol's job.** ACK, NACK, SEQ, CRC-8, retry.
//!
//! Start with [`prelude`]. Map: `docs/API.md`. Hardware: `docs/HARDWARE.md`.
//! Spec: `docs/PROTOCOL.md`.
//!
//! ## What you import (`use psicose::…`)
//!
//! Prefer [`prelude`]. Everything below is a **psicose** type — no foreign
//! crates appear in the public API.
//!
//! | Reach for | When |
//! | --- | --- |
//! | [`Node`] | P2P entry — identity, neighbors, `connect` / `accept` |
//! | [`LinkFace`] | Hardware demux: one UART → Pump TX/RX ends |
//! | [`Wire`] | In-memory A↔B harness (tests). Not the 4-byte frame. |
//! | [`Wire::copy`] | Stop-and-wait copy through the motor |
//! | [`establish`] / [`send_message`] | Cooperative P2P helpers |
//! | [`PeerLink`] | Live link (prefer [`Node`]) |
//! | [`SessionConfig`] | Hello offer — `DEFAULT`, `FORUM`, `SECURE` |
//! | [`Pump`] / [`WindowedPump`] | Reliability over your [`ByteTransport`] |
//! | [`Frame`] / [`crc8`] | Speak the 4-byte envelope yourself |
//! | [`SliceSource`] / [`SliceSink`] | `&[u8]` / `&mut [u8]` as byte ends |
//! | [`ByteTransport`] | **You** implement this for UART/SPI/radio |
//!
//! ## Minimal P2P example
//!
//! ```
//! use psicose::prelude::*;
//!
//! let wire = Wire::new();
//! let (pump_a, pump_b) = wire.link_pumps();
//!
//! let mut alice = Node::<4>::new(PeerId::from_label(b"alice"));
//! let mut bob = Node::<4>::new(PeerId::from_label(b"bob"));
//!
//! let mut a = match alice.connect(pump_a) {
//! Ok(link) => link,
//! Err(_) => return,
//! };
//! let mut b = bob.accept(pump_b);
//!
//! assert!(establish(&mut a, &mut alice, &mut b, &mut bob));
//! assert_eq!(alice.established(), 1);
//! assert_eq!(bob.established(), 1);
//! ```
//!
//! ## Threat model (short)
//!
//! CRC-8 detects accidental corruption. It does **not** authenticate.
//! Confidentiality/authenticity are **outside** this crate — seal messages
//! in your application before they enter the transport if needed.
pub use Error;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;