module OlderVersion
    # Autogenerated using ProtoBuf.jl v1.1.1 on 2025-07-08T10:40:02.200
    # original file: /Users/tdrvostep/.julia/dev/ProtoBuf/test/test_protos/test_messages_for_codec.proto (proto3 syntax)

    import ProtoBuf as PB
    using ProtoBuf: OneOf
    using ProtoBuf.EnumX: @enumx

    abstract type var"##Abstract#TestStruct" end


    struct TestInner
        x::Int64
        r::Union{Nothing,TestInner}
    end
    PB.default_values(::Type{TestInner}) = (;x = zero(Int64), r = nothing)
    PB.field_numbers(::Type{TestInner}) = (;x = 1, r = 2)

    function PB.decode(d::PB.AbstractProtoDecoder, ::Type{<:TestInner})
        x = zero(Int64)
        r = Ref{Union{Nothing,TestInner}}(nothing)
        while !PB.message_done(d)
            field_number, wire_type = PB.decode_tag(d)
            if field_number == 1
                x = PB.decode(d, Int64)
            elseif field_number == 2
                PB.decode!(d, r)
            else
                Base.skip(d, wire_type)
            end
        end
        return TestInner(x, r[])
    end

    function PB.encode(e::PB.AbstractProtoEncoder, x::TestInner)
        initpos = position(e.io)
        x.x != zero(Int64) && PB.encode(e, 1, x.x)
        !isnothing(x.r) && PB.encode(e, 2, x.r)
        return position(e.io) - initpos
    end
    function PB._encoded_size(x::TestInner)
        encoded_size = 0
        x.x != zero(Int64) && (encoded_size += PB._encoded_size(x.x, 1))
        !isnothing(x.r) && (encoded_size += PB._encoded_size(x.r, 2))
        return encoded_size
    end
end
