Files
DotNetAlpm/Alpm/Backup.cs
2020-04-30 17:27:50 -04:00

29 lines
876 B
C#

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