#pragma once

// @generated by thrift-lite.py; do not edit.

#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>

#include <dwarfs/thrift_lite/detail/protocol_helpers.h>
#include <dwarfs/thrift_lite/detail/protocol_methods.h>

namespace dwarfs::thrift::metadata {

inline void chunk::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("chunk");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, block_)) {
    w.write_field_begin("block", ::dwarfs::thrift_lite::ttype::i32_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_)>>::write(w, block_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, offset_)) {
    w.write_field_begin("offset", ::dwarfs::thrift_lite::ttype::i32_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(offset_)>>::write(w, offset_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, size_)) {
    w.write_field_begin("size", ::dwarfs::thrift_lite::ttype::i32_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(size_)>>::write(w, size_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void chunk::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  block_ = {};
  offset_ = {};
  size_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_)>>::read(r, block_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(offset_)>>::read(r, offset_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(size_)>>::read(r, size_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void directory::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("directory");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, parent_entry_)) {
    w.write_field_begin("parent_entry", ::dwarfs::thrift_lite::ttype::i32_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(parent_entry_)>>::write(w, parent_entry_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, first_entry_)) {
    w.write_field_begin("first_entry", ::dwarfs::thrift_lite::ttype::i32_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(first_entry_)>>::write(w, first_entry_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, self_entry_)) {
    w.write_field_begin("self_entry", ::dwarfs::thrift_lite::ttype::i32_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(self_entry_)>>::write(w, self_entry_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void directory::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  parent_entry_ = {};
  first_entry_ = {};
  self_entry_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(parent_entry_)>>::read(r, parent_entry_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(first_entry_)>>::read(r, first_entry_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(self_entry_)>>::read(r, self_entry_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void inode_data::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("inode_data");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, name_index_v2_2_)) {
    w.write_field_begin("name_index_v2_2", ::dwarfs::thrift_lite::ttype::i32_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(name_index_v2_2_)>>::write(w, name_index_v2_2_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, mode_index_)) {
    w.write_field_begin("mode_index", ::dwarfs::thrift_lite::ttype::i32_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mode_index_)>>::write(w, mode_index_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, inode_v2_2_)) {
    w.write_field_begin("inode_v2_2", ::dwarfs::thrift_lite::ttype::i32_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(inode_v2_2_)>>::write(w, inode_v2_2_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, owner_index_)) {
    w.write_field_begin("owner_index", ::dwarfs::thrift_lite::ttype::i32_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(owner_index_)>>::write(w, owner_index_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, group_index_)) {
    w.write_field_begin("group_index", ::dwarfs::thrift_lite::ttype::i32_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(group_index_)>>::write(w, group_index_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, atime_offset_)) {
    w.write_field_begin("atime_offset", ::dwarfs::thrift_lite::ttype::i64_t, 6);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(atime_offset_)>>::write(w, atime_offset_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, mtime_offset_)) {
    w.write_field_begin("mtime_offset", ::dwarfs::thrift_lite::ttype::i64_t, 7);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mtime_offset_)>>::write(w, mtime_offset_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, ctime_offset_)) {
    w.write_field_begin("ctime_offset", ::dwarfs::thrift_lite::ttype::i64_t, 8);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(ctime_offset_)>>::write(w, ctime_offset_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, btime_offset_)) {
    w.write_field_begin("btime_offset", ::dwarfs::thrift_lite::ttype::i64_t, 9);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(btime_offset_)>>::write(w, btime_offset_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, atime_subsec_)) {
    w.write_field_begin("atime_subsec", ::dwarfs::thrift_lite::ttype::i64_t, 10);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(atime_subsec_)>>::write(w, atime_subsec_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, mtime_subsec_)) {
    w.write_field_begin("mtime_subsec", ::dwarfs::thrift_lite::ttype::i64_t, 11);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mtime_subsec_)>>::write(w, mtime_subsec_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, ctime_subsec_)) {
    w.write_field_begin("ctime_subsec", ::dwarfs::thrift_lite::ttype::i64_t, 12);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(ctime_subsec_)>>::write(w, ctime_subsec_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, btime_subsec_)) {
    w.write_field_begin("btime_subsec", ::dwarfs::thrift_lite::ttype::i64_t, 13);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(btime_subsec_)>>::write(w, btime_subsec_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, nlink_minus_one_)) {
    w.write_field_begin("nlink_minus_one", ::dwarfs::thrift_lite::ttype::i32_t, 14);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(nlink_minus_one_)>>::write(w, nlink_minus_one_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void inode_data::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  mode_index_ = {};
  owner_index_ = {};
  group_index_ = {};
  atime_offset_ = {};
  mtime_offset_ = {};
  ctime_offset_ = {};
  btime_offset_ = {};
  atime_subsec_ = {};
  mtime_subsec_ = {};
  ctime_subsec_ = {};
  btime_subsec_ = {};
  nlink_minus_one_ = {};
  name_index_v2_2_ = {};
  inode_v2_2_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(name_index_v2_2_)>>::read(r, name_index_v2_2_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mode_index_)>>::read(r, mode_index_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(inode_v2_2_)>>::read(r, inode_v2_2_);
          skip = false;
        }
        break;

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(owner_index_)>>::read(r, owner_index_);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(group_index_)>>::read(r, group_index_);
          skip = false;
        }
        break;

      case 6:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(atime_offset_)>>::read(r, atime_offset_);
          skip = false;
        }
        break;

      case 7:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mtime_offset_)>>::read(r, mtime_offset_);
          skip = false;
        }
        break;

      case 8:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(ctime_offset_)>>::read(r, ctime_offset_);
          skip = false;
        }
        break;

      case 9:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(btime_offset_)>>::read(r, btime_offset_);
          skip = false;
        }
        break;

      case 10:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(atime_subsec_)>>::read(r, atime_subsec_);
          skip = false;
        }
        break;

      case 11:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mtime_subsec_)>>::read(r, mtime_subsec_);
          skip = false;
        }
        break;

      case 12:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(ctime_subsec_)>>::read(r, ctime_subsec_);
          skip = false;
        }
        break;

      case 13:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(btime_subsec_)>>::read(r, btime_subsec_);
          skip = false;
        }
        break;

      case 14:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(nlink_minus_one_)>>::read(r, nlink_minus_one_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void dir_entry::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("dir_entry");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, name_index_)) {
    w.write_field_begin("name_index", ::dwarfs::thrift_lite::ttype::i32_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(name_index_)>>::write(w, name_index_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, inode_num_)) {
    w.write_field_begin("inode_num", ::dwarfs::thrift_lite::ttype::i32_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(inode_num_)>>::write(w, inode_num_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void dir_entry::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  name_index_ = {};
  inode_num_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(name_index_)>>::read(r, name_index_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(inode_num_)>>::read(r, inode_num_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void fs_options::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("fs_options");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, mtime_only_)) {
    w.write_field_begin("mtime_only", ::dwarfs::thrift_lite::ttype::bool_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mtime_only_)>>::write(w, mtime_only_);
    w.write_field_end();
  }

  if (isset_.test(time_resolution_sec_isset_index)) {
    w.write_field_begin("time_resolution_sec", ::dwarfs::thrift_lite::ttype::i32_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(time_resolution_sec_)>>::write(w, time_resolution_sec_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, packed_chunk_table_)) {
    w.write_field_begin("packed_chunk_table", ::dwarfs::thrift_lite::ttype::bool_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_chunk_table_)>>::write(w, packed_chunk_table_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, packed_directories_)) {
    w.write_field_begin("packed_directories", ::dwarfs::thrift_lite::ttype::bool_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_directories_)>>::write(w, packed_directories_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, packed_shared_files_table_)) {
    w.write_field_begin("packed_shared_files_table", ::dwarfs::thrift_lite::ttype::bool_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_shared_files_table_)>>::write(w, packed_shared_files_table_);
    w.write_field_end();
  }

  if (isset_.test(subsecond_resolution_nsec_multiplier_isset_index)) {
    w.write_field_begin("subsecond_resolution_nsec_multiplier", ::dwarfs::thrift_lite::ttype::i32_t, 6);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(subsecond_resolution_nsec_multiplier_)>>::write(w, subsecond_resolution_nsec_multiplier_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, has_btime_)) {
    w.write_field_begin("has_btime", ::dwarfs::thrift_lite::ttype::bool_t, 7);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(has_btime_)>>::write(w, has_btime_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, inodes_have_nlink_)) {
    w.write_field_begin("inodes_have_nlink", ::dwarfs::thrift_lite::ttype::bool_t, 8);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(inodes_have_nlink_)>>::write(w, inodes_have_nlink_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void fs_options::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  isset_.reset();
  mtime_only_ = {};
  time_resolution_sec_ = {};
  packed_chunk_table_ = {};
  packed_directories_ = {};
  packed_shared_files_table_ = {};
  subsecond_resolution_nsec_multiplier_ = {};
  has_btime_ = {};
  inodes_have_nlink_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(mtime_only_)>>::read(r, mtime_only_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(time_resolution_sec_)>>::read(r, time_resolution_sec_);
          isset_.set(time_resolution_sec_isset_index);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_chunk_table_)>>::read(r, packed_chunk_table_);
          skip = false;
        }
        break;

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_directories_)>>::read(r, packed_directories_);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_shared_files_table_)>>::read(r, packed_shared_files_table_);
          skip = false;
        }
        break;

      case 6:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(subsecond_resolution_nsec_multiplier_)>>::read(r, subsecond_resolution_nsec_multiplier_);
          isset_.set(subsecond_resolution_nsec_multiplier_isset_index);
          skip = false;
        }
        break;

      case 7:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(has_btime_)>>::read(r, has_btime_);
          skip = false;
        }
        break;

      case 8:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(inodes_have_nlink_)>>::read(r, inodes_have_nlink_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void string_table::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("string_table");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, buffer_)) {
    w.write_field_begin("buffer", ::dwarfs::thrift_lite::ttype::string_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(buffer_)>>::write(w, buffer_);
    w.write_field_end();
  }

  if (isset_.test(symtab_isset_index)) {
    w.write_field_begin("symtab", ::dwarfs::thrift_lite::ttype::string_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(symtab_)>>::write(w, symtab_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, index_)) {
    w.write_field_begin("index", ::dwarfs::thrift_lite::ttype::list_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(index_)>>::write(w, index_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, packed_index_)) {
    w.write_field_begin("packed_index", ::dwarfs::thrift_lite::ttype::bool_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_index_)>>::write(w, packed_index_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void string_table::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  isset_.reset();
  buffer_ = {};
  symtab_ = {};
  index_ = {};
  packed_index_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(buffer_)>>::read(r, buffer_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(symtab_)>>::read(r, symtab_);
          isset_.set(symtab_isset_index);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(index_)>>::read(r, index_);
          skip = false;
        }
        break;

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::bool_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(packed_index_)>>::read(r, packed_index_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void inode_size_cache::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("inode_size_cache");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, size_lookup_)) {
    w.write_field_begin("size_lookup", ::dwarfs::thrift_lite::ttype::map_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::map<::dwarfs::thrift_lite::detail::type_class::integral, ::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(size_lookup_)>>::write(w, size_lookup_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, min_chunk_count_)) {
    w.write_field_begin("min_chunk_count", ::dwarfs::thrift_lite::ttype::i64_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(min_chunk_count_)>>::write(w, min_chunk_count_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, allocated_size_lookup_)) {
    w.write_field_begin("allocated_size_lookup", ::dwarfs::thrift_lite::ttype::map_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::map<::dwarfs::thrift_lite::detail::type_class::integral, ::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(allocated_size_lookup_)>>::write(w, allocated_size_lookup_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void inode_size_cache::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  size_lookup_ = {};
  min_chunk_count_ = {};
  allocated_size_lookup_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::map_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::map<::dwarfs::thrift_lite::detail::type_class::integral, ::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(size_lookup_)>>::read(r, size_lookup_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(min_chunk_count_)>>::read(r, min_chunk_count_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::map_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::map<::dwarfs::thrift_lite::detail::type_class::integral, ::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(allocated_size_lookup_)>>::read(r, allocated_size_lookup_);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void history_entry::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("history_entry");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, major_)) {
    w.write_field_begin("major", ::dwarfs::thrift_lite::ttype::byte_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(major_)>>::write(w, major_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, minor_)) {
    w.write_field_begin("minor", ::dwarfs::thrift_lite::ttype::byte_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(minor_)>>::write(w, minor_);
    w.write_field_end();
  }

  if (isset_.test(dwarfs_version_isset_index)) {
    w.write_field_begin("dwarfs_version", ::dwarfs::thrift_lite::ttype::string_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(dwarfs_version_)>>::write(w, dwarfs_version_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, block_size_)) {
    w.write_field_begin("block_size", ::dwarfs::thrift_lite::ttype::i32_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_size_)>>::write(w, block_size_);
    w.write_field_end();
  }

  if (isset_.test(options_isset_index)) {
    w.write_field_begin("options", ::dwarfs::thrift_lite::ttype::struct_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(options_)>>::write(w, options_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void history_entry::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  isset_.reset();
  major_ = {};
  minor_ = {};
  dwarfs_version_ = {};
  block_size_ = {};
  options_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::byte_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(major_)>>::read(r, major_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::byte_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(minor_)>>::read(r, minor_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(dwarfs_version_)>>::read(r, dwarfs_version_);
          isset_.set(dwarfs_version_isset_index);
          skip = false;
        }
        break;

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_size_)>>::read(r, block_size_);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::struct_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(options_)>>::read(r, options_);
          isset_.set(options_isset_index);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

inline void metadata::write(::dwarfs::thrift_lite::protocol_writer_type auto& w) const {
  auto const& opts = w.options();

  w.write_struct_begin("metadata");

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, chunks_)) {
    w.write_field_begin("chunks", ::dwarfs::thrift_lite::ttype::list_t, 1);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(chunks_)>>::write(w, chunks_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, directories_)) {
    w.write_field_begin("directories", ::dwarfs::thrift_lite::ttype::list_t, 2);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(directories_)>>::write(w, directories_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, inodes_)) {
    w.write_field_begin("inodes", ::dwarfs::thrift_lite::ttype::list_t, 3);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(inodes_)>>::write(w, inodes_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, chunk_table_)) {
    w.write_field_begin("chunk_table", ::dwarfs::thrift_lite::ttype::list_t, 4);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(chunk_table_)>>::write(w, chunk_table_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, entry_table_v2_2_)) {
    w.write_field_begin("entry_table_v2_2", ::dwarfs::thrift_lite::ttype::list_t, 5);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(entry_table_v2_2_)>>::write(w, entry_table_v2_2_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, symlink_table_)) {
    w.write_field_begin("symlink_table", ::dwarfs::thrift_lite::ttype::list_t, 6);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(symlink_table_)>>::write(w, symlink_table_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, uids_)) {
    w.write_field_begin("uids", ::dwarfs::thrift_lite::ttype::list_t, 7);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(uids_)>>::write(w, uids_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, gids_)) {
    w.write_field_begin("gids", ::dwarfs::thrift_lite::ttype::list_t, 8);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(gids_)>>::write(w, gids_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, modes_)) {
    w.write_field_begin("modes", ::dwarfs::thrift_lite::ttype::list_t, 9);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(modes_)>>::write(w, modes_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, names_)) {
    w.write_field_begin("names", ::dwarfs::thrift_lite::ttype::list_t, 10);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(names_)>>::write(w, names_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, symlinks_)) {
    w.write_field_begin("symlinks", ::dwarfs::thrift_lite::ttype::list_t, 11);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(symlinks_)>>::write(w, symlinks_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, timestamp_base_)) {
    w.write_field_begin("timestamp_base", ::dwarfs::thrift_lite::ttype::i64_t, 12);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(timestamp_base_)>>::write(w, timestamp_base_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, block_size_)) {
    w.write_field_begin("block_size", ::dwarfs::thrift_lite::ttype::i32_t, 15);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_size_)>>::write(w, block_size_);
    w.write_field_end();
  }

  if (::dwarfs::thrift_lite::detail::should_write_regular(opts, total_fs_size_)) {
    w.write_field_begin("total_fs_size", ::dwarfs::thrift_lite::ttype::i64_t, 16);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(total_fs_size_)>>::write(w, total_fs_size_);
    w.write_field_end();
  }

  if (isset_.test(devices_isset_index)) {
    w.write_field_begin("devices", ::dwarfs::thrift_lite::ttype::list_t, 17);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(devices_)>>::write(w, devices_);
    w.write_field_end();
  }

  if (isset_.test(options_isset_index)) {
    w.write_field_begin("options", ::dwarfs::thrift_lite::ttype::struct_t, 18);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(options_)>>::write(w, options_);
    w.write_field_end();
  }

  if (isset_.test(dir_entries_isset_index)) {
    w.write_field_begin("dir_entries", ::dwarfs::thrift_lite::ttype::list_t, 19);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(dir_entries_)>>::write(w, dir_entries_);
    w.write_field_end();
  }

  if (isset_.test(shared_files_table_isset_index)) {
    w.write_field_begin("shared_files_table", ::dwarfs::thrift_lite::ttype::list_t, 20);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(shared_files_table_)>>::write(w, shared_files_table_);
    w.write_field_end();
  }

  if (isset_.test(total_hardlink_size_isset_index)) {
    w.write_field_begin("total_hardlink_size", ::dwarfs::thrift_lite::ttype::i64_t, 21);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(total_hardlink_size_)>>::write(w, total_hardlink_size_);
    w.write_field_end();
  }

  if (isset_.test(dwarfs_version_isset_index)) {
    w.write_field_begin("dwarfs_version", ::dwarfs::thrift_lite::ttype::string_t, 22);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(dwarfs_version_)>>::write(w, dwarfs_version_);
    w.write_field_end();
  }

  if (isset_.test(create_timestamp_isset_index)) {
    w.write_field_begin("create_timestamp", ::dwarfs::thrift_lite::ttype::i64_t, 23);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(create_timestamp_)>>::write(w, create_timestamp_);
    w.write_field_end();
  }

  if (isset_.test(compact_names_isset_index)) {
    w.write_field_begin("compact_names", ::dwarfs::thrift_lite::ttype::struct_t, 24);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(compact_names_)>>::write(w, compact_names_);
    w.write_field_end();
  }

  if (isset_.test(compact_symlinks_isset_index)) {
    w.write_field_begin("compact_symlinks", ::dwarfs::thrift_lite::ttype::struct_t, 25);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(compact_symlinks_)>>::write(w, compact_symlinks_);
    w.write_field_end();
  }

  if (isset_.test(preferred_path_separator_isset_index)) {
    w.write_field_begin("preferred_path_separator", ::dwarfs::thrift_lite::ttype::i32_t, 26);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(preferred_path_separator_)>>::write(w, preferred_path_separator_);
    w.write_field_end();
  }

  if (isset_.test(features_isset_index)) {
    w.write_field_begin("features", ::dwarfs::thrift_lite::ttype::set_t, 27);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::set<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(features_)>>::write(w, features_);
    w.write_field_end();
  }

  if (isset_.test(category_names_isset_index)) {
    w.write_field_begin("category_names", ::dwarfs::thrift_lite::ttype::list_t, 28);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(category_names_)>>::write(w, category_names_);
    w.write_field_end();
  }

  if (isset_.test(block_categories_isset_index)) {
    w.write_field_begin("block_categories", ::dwarfs::thrift_lite::ttype::list_t, 29);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(block_categories_)>>::write(w, block_categories_);
    w.write_field_end();
  }

  if (isset_.test(reg_file_size_cache_isset_index)) {
    w.write_field_begin("reg_file_size_cache", ::dwarfs::thrift_lite::ttype::struct_t, 30);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(reg_file_size_cache_)>>::write(w, reg_file_size_cache_);
    w.write_field_end();
  }

  if (isset_.test(category_metadata_json_isset_index)) {
    w.write_field_begin("category_metadata_json", ::dwarfs::thrift_lite::ttype::list_t, 31);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(category_metadata_json_)>>::write(w, category_metadata_json_);
    w.write_field_end();
  }

  if (isset_.test(block_category_metadata_isset_index)) {
    w.write_field_begin("block_category_metadata", ::dwarfs::thrift_lite::ttype::map_t, 32);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::map<::dwarfs::thrift_lite::detail::type_class::integral, ::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(block_category_metadata_)>>::write(w, block_category_metadata_);
    w.write_field_end();
  }

  if (isset_.test(metadata_version_history_isset_index)) {
    w.write_field_begin("metadata_version_history", ::dwarfs::thrift_lite::ttype::list_t, 33);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(metadata_version_history_)>>::write(w, metadata_version_history_);
    w.write_field_end();
  }

  if (isset_.test(hole_block_index_isset_index)) {
    w.write_field_begin("hole_block_index", ::dwarfs::thrift_lite::ttype::i32_t, 34);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(hole_block_index_)>>::write(w, hole_block_index_);
    w.write_field_end();
  }

  if (isset_.test(large_hole_size_isset_index)) {
    w.write_field_begin("large_hole_size", ::dwarfs::thrift_lite::ttype::list_t, 35);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(large_hole_size_)>>::write(w, large_hole_size_);
    w.write_field_end();
  }

  if (isset_.test(total_allocated_fs_size_isset_index)) {
    w.write_field_begin("total_allocated_fs_size", ::dwarfs::thrift_lite::ttype::i64_t, 36);
    ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(total_allocated_fs_size_)>>::write(w, total_allocated_fs_size_);
    w.write_field_end();
  }

  w.write_field_stop();
  w.write_struct_end();
}

inline void metadata::read(::dwarfs::thrift_lite::protocol_reader_type auto& r) {
  isset_.reset();
  chunks_ = {};
  directories_ = {};
  inodes_ = {};
  chunk_table_ = {};
  entry_table_v2_2_ = {};
  symlink_table_ = {};
  uids_ = {};
  gids_ = {};
  modes_ = {};
  names_ = {};
  symlinks_ = {};
  timestamp_base_ = {};
  block_size_ = {};
  total_fs_size_ = {};
  devices_ = {};
  options_ = {};
  dir_entries_ = {};
  shared_files_table_ = {};
  total_hardlink_size_ = {};
  dwarfs_version_ = {};
  create_timestamp_ = {};
  compact_names_ = {};
  compact_symlinks_ = {};
  preferred_path_separator_ = {};
  features_ = {};
  category_names_ = {};
  block_categories_ = {};
  reg_file_size_cache_ = {};
  category_metadata_json_ = {};
  block_category_metadata_ = {};
  metadata_version_history_ = {};
  hole_block_index_ = {};
  large_hole_size_ = {};
  total_allocated_fs_size_ = {};

  r.read_struct_begin();

  for (;;) {
    auto field_type = ::dwarfs::thrift_lite::ttype{};
    auto field_id = std::int16_t{};

    r.read_field_begin(field_type, field_id);

    if (field_type == ::dwarfs::thrift_lite::ttype::stop_t) {
      break;
    }

    bool skip = true;

    switch (field_id) {
      case 1:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(chunks_)>>::read(r, chunks_);
          skip = false;
        }
        break;

      case 2:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(directories_)>>::read(r, directories_);
          skip = false;
        }
        break;

      case 3:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(inodes_)>>::read(r, inodes_);
          skip = false;
        }
        break;

      case 4:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(chunk_table_)>>::read(r, chunk_table_);
          skip = false;
        }
        break;

      case 5:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(entry_table_v2_2_)>>::read(r, entry_table_v2_2_);
          skip = false;
        }
        break;

      case 6:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(symlink_table_)>>::read(r, symlink_table_);
          skip = false;
        }
        break;

      case 7:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(uids_)>>::read(r, uids_);
          skip = false;
        }
        break;

      case 8:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(gids_)>>::read(r, gids_);
          skip = false;
        }
        break;

      case 9:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(modes_)>>::read(r, modes_);
          skip = false;
        }
        break;

      case 10:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(names_)>>::read(r, names_);
          skip = false;
        }
        break;

      case 11:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(symlinks_)>>::read(r, symlinks_);
          skip = false;
        }
        break;

      case 12:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(timestamp_base_)>>::read(r, timestamp_base_);
          skip = false;
        }
        break;

      case 15:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(block_size_)>>::read(r, block_size_);
          skip = false;
        }
        break;

      case 16:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(total_fs_size_)>>::read(r, total_fs_size_);
          skip = false;
        }
        break;

      case 17:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(devices_)>>::read(r, devices_);
          isset_.set(devices_isset_index);
          skip = false;
        }
        break;

      case 18:
        if (field_type == ::dwarfs::thrift_lite::ttype::struct_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(options_)>>::read(r, options_);
          isset_.set(options_isset_index);
          skip = false;
        }
        break;

      case 19:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(dir_entries_)>>::read(r, dir_entries_);
          isset_.set(dir_entries_isset_index);
          skip = false;
        }
        break;

      case 20:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(shared_files_table_)>>::read(r, shared_files_table_);
          isset_.set(shared_files_table_isset_index);
          skip = false;
        }
        break;

      case 21:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(total_hardlink_size_)>>::read(r, total_hardlink_size_);
          isset_.set(total_hardlink_size_isset_index);
          skip = false;
        }
        break;

      case 22:
        if (field_type == ::dwarfs::thrift_lite::ttype::binary_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::string, std::remove_cvref_t<decltype(dwarfs_version_)>>::read(r, dwarfs_version_);
          isset_.set(dwarfs_version_isset_index);
          skip = false;
        }
        break;

      case 23:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(create_timestamp_)>>::read(r, create_timestamp_);
          isset_.set(create_timestamp_isset_index);
          skip = false;
        }
        break;

      case 24:
        if (field_type == ::dwarfs::thrift_lite::ttype::struct_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(compact_names_)>>::read(r, compact_names_);
          isset_.set(compact_names_isset_index);
          skip = false;
        }
        break;

      case 25:
        if (field_type == ::dwarfs::thrift_lite::ttype::struct_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(compact_symlinks_)>>::read(r, compact_symlinks_);
          isset_.set(compact_symlinks_isset_index);
          skip = false;
        }
        break;

      case 26:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(preferred_path_separator_)>>::read(r, preferred_path_separator_);
          isset_.set(preferred_path_separator_isset_index);
          skip = false;
        }
        break;

      case 27:
        if (field_type == ::dwarfs::thrift_lite::ttype::set_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::set<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(features_)>>::read(r, features_);
          isset_.set(features_isset_index);
          skip = false;
        }
        break;

      case 28:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(category_names_)>>::read(r, category_names_);
          isset_.set(category_names_isset_index);
          skip = false;
        }
        break;

      case 29:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(block_categories_)>>::read(r, block_categories_);
          isset_.set(block_categories_isset_index);
          skip = false;
        }
        break;

      case 30:
        if (field_type == ::dwarfs::thrift_lite::ttype::struct_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::structure, std::remove_cvref_t<decltype(reg_file_size_cache_)>>::read(r, reg_file_size_cache_);
          isset_.set(reg_file_size_cache_isset_index);
          skip = false;
        }
        break;

      case 31:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::string>, std::remove_cvref_t<decltype(category_metadata_json_)>>::read(r, category_metadata_json_);
          isset_.set(category_metadata_json_isset_index);
          skip = false;
        }
        break;

      case 32:
        if (field_type == ::dwarfs::thrift_lite::ttype::map_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::map<::dwarfs::thrift_lite::detail::type_class::integral, ::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(block_category_metadata_)>>::read(r, block_category_metadata_);
          isset_.set(block_category_metadata_isset_index);
          skip = false;
        }
        break;

      case 33:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::structure>, std::remove_cvref_t<decltype(metadata_version_history_)>>::read(r, metadata_version_history_);
          isset_.set(metadata_version_history_isset_index);
          skip = false;
        }
        break;

      case 34:
        if (field_type == ::dwarfs::thrift_lite::ttype::i32_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(hole_block_index_)>>::read(r, hole_block_index_);
          isset_.set(hole_block_index_isset_index);
          skip = false;
        }
        break;

      case 35:
        if (field_type == ::dwarfs::thrift_lite::ttype::list_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::list<::dwarfs::thrift_lite::detail::type_class::integral>, std::remove_cvref_t<decltype(large_hole_size_)>>::read(r, large_hole_size_);
          isset_.set(large_hole_size_isset_index);
          skip = false;
        }
        break;

      case 36:
        if (field_type == ::dwarfs::thrift_lite::ttype::i64_t) {
          ::dwarfs::thrift_lite::detail::protocol_methods<::dwarfs::thrift_lite::detail::type_class::integral, std::remove_cvref_t<decltype(total_allocated_fs_size_)>>::read(r, total_allocated_fs_size_);
          isset_.set(total_allocated_fs_size_isset_index);
          skip = false;
        }
        break;

  default:
    break;
}
    if (skip) {
      r.skip(field_type);
    }

    r.read_field_end();
  }

  r.read_struct_end();
}

} // namespace dwarfs::thrift::metadata

