using System.Buffers; using Serilog; using UniScan.Device.Connection.Protocol.Payload; namespace UniScan.Device.Connection.Protocol; public class PacketReceivedEventArgs(TPayload payload) : EventArgs { public TPayload Payload { get; } = payload; } /// /// Decodes received payloads from the remote scanner for the Connection to use. /// public interface IDeviceProtocol { /// /// Fired when a payload has been decoded into a Packet and is ready for handlers to use /// public event EventHandler> PacketReceived; /// /// Logger for the protocol /// protected abstract ILogger Logger { get; set; } /// /// Decodes a payload and fires PacketReceived once usable /// /// The buffer from the remote stream /// Whether or not the payload was handled successfully, a return value of false may indicate that extra data is required before handling the payload. bool HandlePayload(ref ReadOnlySequence buffer); /// /// Attempts to skip a payload, used for skipping invalid or unknown data /// /// The buffer from the remote stream /// Whether skipping was successful bool TrySkipPayload(ref ReadOnlySequence buffer); }