feat(call): implement CallConnection with imported-ops overlay (Layer 2) and call/subscribe/abort methods

Implements CallConnection in src/protocol/connection.rs representing an
established alknet/call connection (either direction). Holds the Layer 2
imported-ops overlay (ADR-024) as Arc<RwLock<HashMap>>.

- register_imported / register_imported_all add to the connection overlay
- overlay_env returns an OperationEnv dispatching to imported ops; contains()
  returns true only for ops in the overlay
- call() opens a stream, sends call.requested, registers in PendingRequestMap,
  spawns a stream reader, resolves on first call.responded
- subscribe() sends call.requested and yields call.responded until
  call.completed/call.aborted via a SubscriptionStream wrapping the mpsc receiver
- abort() sends call.aborted for the request ID and removes the pending entry
- connection drop drops the overlay (no explicit deregistration needed)

Exposes MockConnection trait and Connection::from_mock in alknet-core so
cross-crate tests can construct mock connections without real QUIC. Removes
two unused test helpers in env.rs that triggered dead-code warnings under
-D warnings. Adds parking_lot dep for the overlay RwLock and pending Mutex.

9 new connection tests (102 total in alknet-call). Clippy clean.
This commit is contained in:
2026-06-23 15:16:10 +00:00
parent 4f10af2295
commit ddc6c07fea
5 changed files with 576 additions and 28 deletions

View File

@@ -368,7 +368,7 @@ enum ConnectionKind {
}
#[allow(dead_code)]
pub(crate) trait MockConnection: Send + Sync {
pub trait MockConnection: Send + Sync {
fn remote_alpn(&self) -> &[u8];
fn remote_addr(&self) -> Option<SocketAddr>;
fn close(&self, code: u32, reason: &str);
@@ -406,7 +406,7 @@ impl Connection {
}
#[allow(dead_code)]
pub(crate) fn from_mock(mock: Arc<dyn MockConnection + Send + Sync>) -> Self {
pub fn from_mock(mock: Arc<dyn MockConnection + Send + Sync>) -> Self {
let alpn = mock.remote_alpn().to_vec();
Self {
kind: ConnectionKind::Mock(mock),
@@ -523,6 +523,7 @@ mod tests {
closed: std::sync::Mutex<Option<(u32, String)>>,
}
#[allow(dead_code)]
impl MockConnection for MockConn {
fn remote_alpn(&self) -> &[u8] {
self.alpn