31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
namespace EM.LowLevel
|
|
{
|
|
/// <summary>
|
|
/// Builds device/peripheral commands from C#-friendly types (enums, records, structs, etc.).
|
|
/// </summary>
|
|
public interface ICommandBuilder
|
|
{
|
|
|
|
/// <summary>
|
|
/// Build a command payload (already framed or raw depending on implementation contract) from a
|
|
/// strongly-typed command description.
|
|
/// </summary>
|
|
/// <typeparam name="TCommand">
|
|
/// Command type (e.g., an enum or a record/struct)
|
|
/// </typeparam>
|
|
/// <param name="command">
|
|
/// Command value to build
|
|
/// </param>
|
|
/// <returns>
|
|
/// Command bytes
|
|
/// </returns>
|
|
ReadOnlyMemory<byte> Build<TCommand>(TCommand command) where TCommand: notnull;
|
|
|
|
/// <summary>
|
|
/// Try-build variant to avoid throwing and allow buffer reuse strategies.
|
|
/// </summary>
|
|
bool TryBuild<TCommand>(TCommand command, out ReadOnlyMemory<byte> bytes) where TCommand: notnull;
|
|
|
|
}
|
|
}
|