aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils/src/VnEncoding.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-09 01:48:28 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-09 01:48:28 -0500
commit5ddef0fcb742e77b99a0e17015d2eea0a1d4131a (patch)
treec1c88284b11b70d9f373215d8d54e8a168cc5700 /lib/Utils/src/VnEncoding.cs
parentdab71d5597fdfbe71f6ac310a240835716e952a5 (diff)
Omega cache, session, and account provider complete overhaul
Diffstat (limited to 'lib/Utils/src/VnEncoding.cs')
-rw-r--r--lib/Utils/src/VnEncoding.cs64
1 files changed, 2 insertions, 62 deletions
diff --git a/lib/Utils/src/VnEncoding.cs b/lib/Utils/src/VnEncoding.cs
index 89863aa..c9cdbb0 100644
--- a/lib/Utils/src/VnEncoding.cs
+++ b/lib/Utils/src/VnEncoding.cs
@@ -74,67 +74,7 @@ namespace VNLib.Utils
throw;
}
}
-
- /// <summary>
- /// Attempts to deserialze a json object from a stream of UTF8 data
- /// </summary>
- /// <typeparam name="T">The type of the object to deserialize</typeparam>
- /// <param name="data">Binary data to read from</param>
- /// <param name="options"><see cref="JsonSerializerOptions"/> object to pass to deserializer</param>
- /// <returns>The object decoded from the stream</returns>
- /// <exception cref="JsonException"></exception>
- /// <exception cref="NotSupportedException"></exception>
- public static T? JSONDeserializeFromBinary<T>(Stream? data, JsonSerializerOptions? options = null)
- {
- //Return default if null
- if (data == null)
- {
- return default;
- }
- //Create a memory stream as a buffer
- using VnMemoryStream ms = new();
- //Copy stream data to memory
- data.CopyTo(ms, null);
- if (ms.Length > 0)
- {
- //Rewind
- ms.Position = 0;
- //Recover data from stream
- return ms.AsSpan().AsJsonObject<T>(options);
- }
- //Stream is empty
- return default;
- }
- /// <summary>
- /// Attempts to deserialze a json object from a stream of UTF8 data
- /// </summary>
- /// <param name="data">Binary data to read from</param>
- /// <param name="type"></param>
- /// <param name="options"><see cref="JsonSerializerOptions"/> object to pass to deserializer</param>
- /// <returns>The object decoded from the stream</returns>
- /// <exception cref="JsonException"></exception>
- /// <exception cref="NotSupportedException"></exception>
- public static object? JSONDeserializeFromBinary(Stream? data, Type type, JsonSerializerOptions? options = null)
- {
- //Return default if null
- if (data == null)
- {
- return default;
- }
- //Create a memory stream as a buffer
- using VnMemoryStream ms = new();
- //Copy stream data to memory
- data.CopyTo(ms, null);
- if (ms.Length > 0)
- {
- //Rewind
- ms.Position = 0;
- //Recover data from stream
- return JsonSerializer.Deserialize(ms.AsSpan(), type, options);
- }
- //Stream is empty
- return default;
- }
+
/// <summary>
/// Attempts to deserialze a json object from a stream of UTF8 data
/// </summary>
@@ -315,7 +255,7 @@ namespace VNLib.Utils
//Fill remaining bytes with padding chars
for(; rounds < 8; rounds++)
{
- //Append trailing '='
+ //Append trailing '=' padding character
writer.Append('=');
}
}