2023-09-08 16:54:07 -04:00
|
|
|
using System.IO;
|
|
|
|
|
|
2023-09-15 22:34:47 -04:00
|
|
|
namespace SabreTools.Serialization.Interfaces
|
2023-09-08 16:54:07 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines how to serialize to and from Streams
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IStreamSerializer<T>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deserialize a Stream into <typeparamref name="T"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
|
|
|
|
/// <param name="data">Stream to parse</param>
|
|
|
|
|
/// <returns>Filled object on success, null on error</returns>
|
|
|
|
|
T? Deserialize(Stream? data);
|
2023-09-08 18:39:57 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Serialize a <typeparamref name="T"/> into a Stream
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">Type of object to serialize from</typeparam>
|
|
|
|
|
/// <param name="obj">Data to serialize</param>
|
|
|
|
|
/// <returns>Filled object on success, null on error</returns>
|
|
|
|
|
Stream? Serialize(T? obj);
|
2023-09-08 16:54:07 -04:00
|
|
|
}
|
|
|
|
|
}
|