// // IStringConverter.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Remora.Results; namespace NosSmooth.PacketSerializer.Abstractions; /// /// Base type for converting types. /// public interface IStringConverter { /// /// Convert the data from the enumerator to the given type. /// /// The packet string enumerator with the current position. /// The deserialization options. /// The parsed object or an error. public Result Deserialize(ref PacketStringEnumerator stringEnumerator, DeserializeOptions options); /// /// Serializes the given object to string by appending to the packet string builder. /// /// The object to serialize. /// The string builder to append to. /// A result that may or may not have succeeded. public Result Serialize(object? obj, ref PacketStringBuilder builder); } /// /// Converts string to an object. /// /// /// Used for converting packets. /// /// The type that can be parsed. public interface IStringConverter : IStringConverter { /// /// Convert the data from the enumerator to the given type. /// /// The packet string enumerator with the current position. /// The deserialization options. /// The parsed object or an error. public new Result Deserialize(ref PacketStringEnumerator stringEnumerator, DeserializeOptions options); /// /// Serializes the given object to string by appending to the packet string builder. /// /// The object to serialize. /// The string builder to append to. /// A result that may or may not have succeeded. public Result Serialize(TParseType? obj, ref PacketStringBuilder builder); }