38 lines
No EOL
898 B
C#
38 lines
No EOL
898 B
C#
using System;
|
|
|
|
using FrostFS.Refs;
|
|
using FrostFS.SDK.Cryptography;
|
|
|
|
using Google.Protobuf;
|
|
|
|
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
|
|
|
public static class ContainerIdMapper
|
|
{
|
|
public static ContainerID ToMessage(this FrostFsContainerId model)
|
|
{
|
|
if (model is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(model));
|
|
}
|
|
|
|
var containerId = model.GetValue() ?? throw new ArgumentNullException(nameof(model));
|
|
|
|
var message = new ContainerID
|
|
{
|
|
Value = UnsafeByteOperations.UnsafeWrap(Base58.Decode(containerId))
|
|
};
|
|
|
|
return message!;
|
|
}
|
|
|
|
public static FrostFsContainerId ToModel(this ContainerID message)
|
|
{
|
|
if (message is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(message));
|
|
}
|
|
|
|
return new FrostFsContainerId(Base58.Encode(message.Value.Span));
|
|
}
|
|
} |