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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Message edit data for media
/// See <a href="https://corefork.telegram.org/constructor/messages.messageEditData" />
///</summary>
[TlObject(0x26b5dde6)]
public sealed class TMessageEditData : IMessageEditData
{
    public uint ConstructorId => 0x26b5dde6;
    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags { get; set; }

    ///<summary>
    /// Media caption, if the specified media's caption can be edited
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Caption { get; set; }

    public void ComputeFlag()
    {
        if (Caption) { Flags = Flags.SetBit(0); }
    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);

    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Caption = true; }
    }
}