// Copyright Epic Games, Inc. All Rights Reserved.
using System.ComponentModel;
using EpicGames.Core;
namespace EpicGames.Horde.Logs
{
///
/// Identifier for a log
///
/// Id to construct from
[LogValueType]
[JsonSchemaString]
[TypeConverter(typeof(BinaryIdTypeConverter))]
[BinaryIdConverter(typeof(LogIdConverter))]
public readonly record struct LogId(BinaryId Id)
{
///
/// Constant value for empty user id
///
public static LogId Empty { get; } = new LogId(default);
///
public static LogId Parse(string text) => new LogId(BinaryId.Parse(text));
///
public static bool TryParse(string text, out LogId id)
{
if (BinaryId.TryParse(text, out BinaryId objectId))
{
id = new LogId(objectId);
return true;
}
else
{
id = default;
return false;
}
}
///
public override string ToString() => Id.ToString();
}
///
/// Converter to and from instances.
///
class LogIdConverter : BinaryIdConverter
{
///
public override LogId FromBinaryId(BinaryId id) => new LogId(id);
///
public override BinaryId ToBinaryId(LogId value) => value.Id;
}
}