commit 67a84e4854d1ef7d06f3ec9311bed765905608dd
parent e05fba1550d63f52997073c7684ca0b700fb8b6d
Author: Zack Newman <zack@philomathiclife.com>
Date: Tue, 21 Mar 2023 18:56:29 -0600
changed deserializable interfaces to have static functions
Diffstat:
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/BinDe.cs b/BinDe.cs
@@ -8,7 +8,7 @@ using System;
#region Namespaces
namespace Serde.Bin.De {
#region Types
- public interface IBinDeserializableAdapter<T>: IDeserializableAdapter<T> where T: notnull {
+ public interface IBinDeserializable<TSelf>: IDeserializable<TSelf> where TSelf: notnull, IBinDeserializable<TSelf> {
#region Type-level Constructors
#endregion
@@ -29,10 +29,10 @@ namespace Serde.Bin.De {
#endregion
#region Type-level Functions
+ public static abstract Result<TSelf, Error> De(ref Deserializer des);
#endregion
#region Instance Functions
- public abstract Result<T, Error> De(ref Deserializer des);
#endregion
#region Operators
@@ -180,7 +180,7 @@ namespace Serde.Bin.De {
public Result<I128, Error> DeserializeI128() => DeserializeUnsafe<I128>();
public Result<int, Error> DeserializeInt() => DeserializeUnsafe<int>();
public Result<long, Error> DeserializeLong() => DeserializeUnsafe<long>();
- public Result<Maybe<TSome>, Error> DeserializeMaybe<TSome, TAdapter>() where TSome: notnull where TAdapter: IBinDeserializableAdapter<TSome>, new() {
+ public Result<Maybe<TSome>, Error> DeserializeMaybe<TSome>() where TSome: notnull, IBinDeserializable<TSome> {
var copy = this;
var val = copy.DeserializeByte();
@@ -192,7 +192,7 @@ namespace Serde.Bin.De {
this = copy;
return new(Maybe<TSome>.None());
} else if (v == byte.MaxValue) {
- var res = new TAdapter().De(ref copy);
+ var res = TSome.De(ref copy);
if (res.IsOK) {
this = copy;
diff --git a/De.cs b/De.cs
@@ -371,7 +371,7 @@ namespace Serde.De {
}
#endregion
}
- public interface IDeserializableAdapter<T> where T: notnull {
+ public interface IDeserializable<TSelf> where TSelf: notnull, IDeserializable<TSelf> {
#region Type-level Constructors
#endregion
@@ -392,10 +392,10 @@ namespace Serde.De {
#endregion
#region Type-level Functions
+ public static abstract Result<TSelf, Error> Deserialize<TDes>(ref TDes des) where TDes: notnull, IDeserializer;
#endregion
#region Instance Functions
- public abstract Result<T, Error> Deserialize<TDes>(ref TDes des) where TDes: notnull, IDeserializer;
#endregion
#region Operators
@@ -442,7 +442,7 @@ namespace Serde.De {
public abstract Result<I128, Error> DeserializeI128();
public abstract Result<int, Error> DeserializeInt();
public abstract Result<long, Error> DeserializeLong();
- public abstract Result<Maybe<TSome>, Error> DeserializeMaybe<TSome, TAdapter>() where TSome: notnull where TAdapter: IDeserializableAdapter<TSome>, new();
+ public abstract Result<Maybe<TSome>, Error> DeserializeMaybe<TSome>() where TSome: notnull, IDeserializable<TSome>;
public abstract Result<sbyte, Error> DeserializeSbyte();
public abstract Result<short, Error> DeserializeShort();
public abstract Result<TimeSpan, Error> DeserializeTimeSpan();