A Core/NosSmooth.Packets/Converters/Basic/CharTypeConverter.cs => Core/NosSmooth.Packets/Converters/Basic/CharTypeConverter.cs +27 -0
@@ 0,0 1,27 @@
+//
+// CharTypeConverter.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 NosSmooth.Packets.Errors;
+using Remora.Results;
+
+namespace NosSmooth.Packets.Converters.Basic;
+
+/// <summary>
+/// Converter of <see cref="char"/>.
+/// </summary>
+public class CharTypeConverter : BasicTypeConverter<char>
+{
+ /// <inheritdoc />
+ protected override Result<char> Deserialize(string value)
+ {
+ if (value.Length != 1)
+ {
+ return new CouldNotConvertError(this, value, "The token is not one character long.");
+ }
+
+ return value[0];
+ }
+}<
\ No newline at end of file
A Core/NosSmooth.Packets/Converters/Basic/StringTypeConverter.cs => Core/NosSmooth.Packets/Converters/Basic/StringTypeConverter.cs +21 -0
@@ 0,0 1,21 @@
+//
+// StringTypeConverter.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.Packets.Converters.Basic;
+
+/// <summary>
+/// Converter of <see cref="string"/>.
+/// </summary>
+public class StringTypeConverter : BasicTypeConverter<string>
+{
+ /// <inheritdoc />
+ protected override Result<string?> Deserialize(string value)
+ {
+ return value;
+ }
+}<
\ No newline at end of file