init
Some checks failed
CI / Rust (push) Successful in 20s
CI / Android (push) Failing after 8m35s

This commit is contained in:
2026-05-31 15:36:07 +03:30
commit 4ffbc3bffe
61 changed files with 2760 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
//! Transport abstraction for USB, Wi-Fi, and hotspot-local VSHP sessions.
use std::io;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TransportKind {
UsbAccessory,
WifiLan,
LocalOnlyHotspot,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TransportDescriptor {
pub kind: TransportKind,
pub label: String,
pub mtu_hint: Option<u16>,
}
pub trait PacketTransport {
fn descriptor(&self) -> &TransportDescriptor;
fn send_frame(&mut self, bytes: &[u8]) -> io::Result<()>;
fn receive_frame(&mut self, buffer: &mut [u8]) -> io::Result<usize>;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ResumeToken {
pub session_id: [u8; 16],
pub transport_generation: u64,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Backpressure {
pub queued_bytes: usize,
pub max_queue_bytes: usize,
}
impl Backpressure {
pub fn should_pause_reads(&self) -> bool {
self.queued_bytes >= self.max_queue_bytes
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn backpressure_pauses_when_queue_is_full() {
assert!(Backpressure {
queued_bytes: 1024,
max_queue_bytes: 1024,
}
.should_pause_reads());
}
}