using System; using System.Runtime.InteropServices; namespace Foodsoft.Alpm { public readonly struct Backup : IEquatable { public string Name { get; } public string? Hash { get; } public bool Equals(Backup other) { return Name == other.Name && Hash == other.Hash; } public override bool Equals(object? obj) { return obj is Backup other && Equals(other); } public override int GetHashCode() { return HashCode.Combine(Name, Hash); } [StructLayout(LayoutKind.Sequential)] private readonly struct NativeBackup { internal readonly IntPtr name; internal readonly IntPtr hash; } internal unsafe Backup(IntPtr ptr) { var native = (NativeBackup*) ptr; Name = Marshal.PtrToStringUTF8(native->name)!; Hash = Marshal.PtrToStringUTF8(native->hash)!; } } }