Class GuidSerializer
Type serializer for Guid values. Converts each GUID to and from the
standard hyphenated 8-4-4-4-12 string representation (format specifier "D"),
for example 550e8400-e29b-41d4-a716-446655440000.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class GuidSerializer : TypeSerializerBase<Guid>, ITypeSerializer<Guid>, ITypeSerializer
Remarks
The "D" format is chosen over "B" (braces) or "N" (no hyphens)
for maximum human-readability and cross-platform JSON compatibility. On read,
Parse(string) accepts all standard Guid format strings, so data
produced by other serializers using a different format will still deserialize correctly.
Use the shared Instance singleton rather than creating new instances;
GuidSerializer carries no mutable state and is safe to share across threads.
Fields
Instance
Shared, reusable singleton instance of GuidSerializer.
Prefer this over allocating a new instance wherever a GuidSerializer is needed.
Declaration
public static readonly GuidSerializer Instance
Field Value
| Type | Description |
|---|---|
| GuidSerializer |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a GUID string from the reader and parses it back to a Guid.
Declaration
public override Guid Read(IScyllaReader reader, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaReader | reader | The reader positioned at a string token. Never |
| ISerializationContext | context | The active serialization context. Never |
Returns
| Type | Description |
|---|---|
| Guid | The deserialized Guid value. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| FormatException | Thrown by Parse(string) if the string is not a valid GUID representation. |
Write(Guid, IScyllaWriter, ISerializationContext)
Converts value to a hyphenated GUID string ("D" format) and
writes it to the output via WriteString(string).
Declaration
public override void Write(Guid value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | value | The Guid to serialize. |
| IScyllaWriter | writer | The writer that receives the serialized token. Never |
| ISerializationContext | context | The active serialization context. Never |