import Foundation

/// A bidirectional, ordered pipe of whole frames — the one transport seam shared by the host
/// server, the iOS client, and tests (SYNC_PROTOCOL §2 layer cake). Frames delivered by
/// `frames()` are already de-framed (length prefix stripped by the implementation); `send`
/// re-frames. The LAN implementation wraps NWConnection; tests use an in-memory pair.
public protocol FrameChannel: AnyObject, Sendable {
    /// Short, non-sensitive description for logs (e.g. "192.168.1.5:51900").
    var peerDescription: String { get }
    /// Ordered inbound frames; the stream finishes when the peer disconnects.
    func frames() -> AsyncStream<Data>
    /// Enqueue one frame. Synchronous so sealing + enqueuing stay atomic within one actor
    /// method, keeping the Noise per-direction nonce order identical to the wire order.
    func send(_ frame: Data)
    func close()
}
