// <auto-generated/>
// ReSharper disable All

namespace MyTelegram.Schema;

///<summary>
/// SHA256 Hash of an uploaded file, to be checked for validity after download
/// See <a href="https://corefork.telegram.org/constructor/fileHash" />
///</summary>
[TlObject(0xf39b035c)]
public sealed class TFileHash : IFileHash
{
    public uint ConstructorId => 0xf39b035c;
    ///<summary>
    /// Offset from where to start computing SHA-256 hash
    ///</summary>
    public long Offset { get; set; }

    ///<summary>
    /// Length
    ///</summary>
    public int Limit { get; set; }

    ///<summary>
    /// SHA-256 Hash of file chunk, to be checked for validity after download
    ///</summary>
    public ReadOnlyMemory<byte> Hash { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Offset);
        writer.Write(Limit);
        writer.Write(Hash);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Offset = buffer.ReadInt64();
        Limit = buffer.ReadInt32();
        Hash = buffer.ReadBytes();
    }
}