Skip to content

Commit

Permalink
Added a Clear function to Serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
abledbody committed Aug 26, 2023
1 parent 471a92e commit 7df2798
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Assets/QuickBin/Serializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ public sealed partial class Serializer {
public static implicit operator byte[](Serializer serializer) => serializer.bytes.ToArray();
public static implicit operator List<byte>(Serializer serializer) => serializer.bytes;

/// <summary>
/// Clears the internal List so that the Serializer can be reused.
/// </summary>
/// <returns>This Serializer.</returns>
public Serializer Clear() {
bytes.Clear();
return this;
}

private Serializer WriteGeneric<T>(T value, Func<T, byte> f) {
bytes.Add(f(value));
return this;
Expand Down

0 comments on commit 7df2798

Please sign in to comment.