30 lines
874 B
C#
30 lines
874 B
C#
namespace EM.LowLevel
|
|
{
|
|
/// <summary>
|
|
/// Decodes device-specific binary responses into C#-friendly models.
|
|
/// </summary>
|
|
public interface IDataDecoder
|
|
{
|
|
|
|
/// <summary>
|
|
/// Decode a response of a known type into a model.
|
|
/// </summary>
|
|
/// <typeparam name="TModel">
|
|
/// Target model type
|
|
/// </typeparam>
|
|
/// <param name="payload">
|
|
/// Raw or deframed payload depending on transport contract
|
|
/// </param>
|
|
/// <returns>
|
|
/// Decoded model
|
|
/// </returns>
|
|
TModel Decode<TModel>(ReadOnlySpan<byte> payload);
|
|
|
|
/// <summary>
|
|
/// Try-decode variant to avoid throwing on partial/bad frames.
|
|
/// </summary>
|
|
bool TryDecode<TModel>(ReadOnlySpan<byte> payload, out TModel model);
|
|
|
|
}
|
|
}
|