| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using System.Buffers; |
| | 4 | |
|
| | 5 | | namespace ZeroC.Slice; |
| | 6 | |
|
| | 7 | | /// <summary>Provides an extension method for <see cref="SliceDecoder" /> to decode a <c>WellKnownTypes::Uuid</c> into a |
| | 8 | | /// <see cref="Guid" />.</summary> |
| | 9 | | public static class UuidSliceDecoderExtensions |
| | 10 | | { |
| | 11 | | /// <summary>Decodes a <c>WellKnownTypes::Uuid</c>.</summary> |
| | 12 | | /// <param name="decoder">The Slice decoder.</param> |
| | 13 | | /// <returns>The Uuid decoded as a <see cref="Guid"/>.</returns> |
| | 14 | | public static Guid DecodeUuid(this ref SliceDecoder decoder) |
| 6 | 15 | | { |
| 6 | 16 | | using IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(16); |
| 6 | 17 | | Span<byte> span = owner.Memory.Span[..16]; |
| 6 | 18 | | decoder.CopyTo(span); |
| 6 | 19 | | return new Guid(span); |
| 6 | 20 | | } |
| | 21 | | } |