public static void Encode(Stream stream, BObject obj, string prefix = null) { if (prefix is not null) { stream.Write(Encoding.UTF8.GetBytes(prefix)); } stream.WriteByte(0); EncodeNoPrefix(stream, obj); }
public static ValueTask EncodeAsync(Stream stream, BObject obj, string prefix = null, CancellationToken cancellationToken = default) { return(stream.WriteAsync(Encode(obj, prefix), cancellationToken)); }
public static byte[] EncodeNoPrefix(BObject obj) { using var mem = new MemoryStream(1500); EncodeNoPrefix(mem, obj); return(mem.ToArray()); }
public static void EncodeNoPrefix(Stream stream, BObject obj) { obj.Write(stream); }
public static byte[] Encode(BObject obj, string prefix = null) { using var mem = new MemoryStream(1500); Encode(mem, obj, prefix); return(mem.ToArray()); }
public static ValueTask EncodeNoPrefixAsync(Stream stream, BObject obj, CancellationToken cancellationToken = default) { return(stream.WriteAsync(EncodeNoPrefix(obj), cancellationToken)); }