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

namespace MyTelegram.Schema.Upload;

///<summary>
/// Represents a chunk of an <a href="https://corefork.telegram.org/api/files">HTTP webfile</a> downloaded through telegram's secure MTProto servers
/// See <a href="https://corefork.telegram.org/constructor/upload.webFile" />
///</summary>
[TlObject(0x21e753bc)]
public sealed class TWebFile : IWebFile
{
    public uint ConstructorId => 0x21e753bc;
    ///<summary>
    /// File size
    ///</summary>
    public int Size { get; set; }

    ///<summary>
    /// Mime type
    ///</summary>
    public string MimeType { get; set; }

    ///<summary>
    /// File type
    /// See <a href="https://corefork.telegram.org/type/storage.FileType" />
    ///</summary>
    public MyTelegram.Schema.Storage.IFileType FileType { get; set; }

    ///<summary>
    /// Modified time
    ///</summary>
    public int Mtime { get; set; }

    ///<summary>
    /// Data
    ///</summary>
    public ReadOnlyMemory<byte> Bytes { get; set; }

    public void ComputeFlag()
    {

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Size);
        writer.Write(MimeType);
        writer.Write(FileType);
        writer.Write(Mtime);
        writer.Write(Bytes);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Size = buffer.ReadInt32();
        MimeType = buffer.ReadString();
        FileType = buffer.Read<MyTelegram.Schema.Storage.IFileType>();
        Mtime = buffer.ReadInt32();
        Bytes = buffer.ReadBytes();
    }
}