using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace EM.LowLevel
{
///
/// High-level transport abstraction for device communication. Derives from Stream and
/// encapsulates initialization/handshake and frame (header/tail/checksum) handling as needed
/// by the device. Implementations may wrap SerialPort, Sockets, USB, etc.
///
public abstract class PortStream : Stream
{
///
/// Optional bytes available hint if the transport can provide it.
///
public virtual long? BytesAvailable => null;
///
/// Close the underlying transport and release resources.
///
public abstract override void Close();
///
/// Ensure the port is opened and ready. Idempotent. May perform device-specific
/// handshakes.
///
public abstract ValueTask OpenAsync(CancellationToken cancellationToken = default);
// Concrete transports must implement Stream's abstract members.
// Seek-related members are typically not supported and should throw NotSupportedException.
}
}