Ser.cs (3276B)
1 using Std; 2 using Std.Error; 3 using Std.Maybe; 4 using Std.Num; 5 using Std.Result; 6 using System; 7 #region Namespaces 8 namespace Serde.Ser { 9 #region Types 10 public interface ISerializable { 11 12 #region Type-level Constructors 13 #endregion 14 15 #region Instance Constructors 16 #endregion 17 18 #region Type-level Fields 19 #endregion 20 21 #region Instance Fields 22 #endregion 23 24 #region Type-level Properties 25 #endregion 26 27 #region Instance Properties 28 #endregion 29 30 #region Type-level Functions 31 #endregion 32 33 #region Instance Functions 34 public abstract Result<TOK, TErr> Serialize<TSer, TOK, TErr>(ref TSer ser) where TOK: notnull where TErr: notnull, IError where TSer: ISerializer<TOK, TErr>; 35 #endregion 36 37 #region Operators 38 #endregion 39 40 #region Types 41 #endregion 42 } 43 public interface ISerializer<TOK, TErr> where TOK: notnull where TErr: notnull, IError { 44 45 #region Type-level Constructors 46 #endregion 47 48 #region Instance Constructors 49 #endregion 50 51 #region Type-level Fields 52 #endregion 53 54 #region Instance Fields 55 #endregion 56 57 #region Type-level Properties 58 #endregion 59 60 #region Instance Properties 61 #endregion 62 63 #region Type-level Functions 64 #endregion 65 66 #region Instance Functions 67 public abstract Result<TOK, TErr> Serialize(ReadOnlySpan<byte> bytes); 68 public abstract Result<TOK, TErr> SerializeBool(bool val); 69 public abstract Result<TOK, TErr> SerializeByte(byte val); 70 public abstract Result<TOK, TErr> SerializeChar(char val); 71 public abstract Result<TOK, TErr> SerializeChars(ReadOnlySpan<char> val); 72 public abstract Result<TOK, TErr> SerializeDateTime(DateTime val); 73 public abstract Result<TOK, TErr> SerializeDateTimeOffset(DateTimeOffset val); 74 public abstract Result<TOK, TErr> SerializeDecimal(decimal val); 75 public abstract Result<TOK, TErr> SerializeDouble(double val); 76 public abstract Result<TOK, TErr> SerializeFloat(float val); 77 public abstract Result<TOK, TErr> SerializeGuid(Guid val); 78 public abstract Result<TOK, TErr> SerializeI128(I128 val); 79 public abstract Result<TOK, TErr> SerializeInt(int val); 80 public abstract Result<TOK, TErr> SerializeLong(long val); 81 public abstract Result<TOK, TErr> SerializeMaybe<TSome>(Maybe<TSome> val) where TSome: notnull, ISerializable; 82 public abstract Result<TOK, TErr> SerializeSbyte(sbyte val); 83 public abstract Result<TOK, TErr> SerializeShort(short val); 84 public abstract Result<TOK, TErr> SerializeTimeSpan(TimeSpan val); 85 public abstract Result<TOK, TErr> SerializeU128(U128 val); 86 public abstract Result<TOK, TErr> SerializeUint(uint val); 87 public abstract Result<TOK, TErr> SerializeUlong(ulong val); 88 public abstract Result<TOK, TErr> SerializeUnit(Unit _); 89 public abstract Result<TOK, TErr> SerializeUshort(ushort val); 90 #endregion 91 92 #region Operators 93 #endregion 94 95 #region Types 96 #endregion 97 } 98 #endregion 99 100 #region Namespaces 101 #endregion 102 } 103 #endregion