import Foundation
import NucleicProtocol

// The host-side transport seam (SYNC_PROTOCOL §2 layer cake). Connections use the shared
// `FrameChannel` (NucleicProtocol) so the client, server, and tests share one abstraction;
// only the listener — which accepts connections — is host-only and lives here.

/// Accepts client connections. The LAN implementation advertises Bonjour + listens on TCP.
public protocol SyncListener: AnyObject, Sendable {
    /// Begin listening/advertising and yield each accepted connection.
    func start() throws -> AsyncStream<any FrameChannel>
    func stop()
}

public enum SyncTransportError: Error, Equatable {
    case listenerFailed(String)
    case connectionClosed
}
