Files
SabreTools.Serialization/Interfaces/IStringSerializer.cs

24 lines
917 B
C#
Raw Permalink Normal View History

2023-10-24 23:20:27 -04:00
namespace SabreTools.Serialization.Interfaces
{
/// <summary>
/// Defines how to serialize to and from strings
/// </summary>
public interface IStringSerializer<T>
{
/// <summary>
/// Deserialize a string into <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to deserialize to</typeparam>
/// <param name="str">String to deserialize from</param>
/// <returns>Filled object on success, null on error</returns>
T? Deserialize(string? str);
/// <summary>
/// Serialize a <typeparamref name="T"/> into a string
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>
/// <returns>Filled string on successful serialization, null otherwise</returns>
string? Serialize(T? obj);
}
}