// Auto-generated from BCH_BKEY_TYPES() — do not edit

/// A bkey type together with its val struct's type info.
pub struct BkeyTypeInfo {
    pub name: &'static str,
    pub type_: u32,
    pub info: &'static StructInfo,
}

pub static BKEY_TYPE_INFO: &[BkeyTypeInfo] = &[
    BkeyTypeInfo { name: "deleted", type_: 0, info: <crate::c::bch_deleted as TypeInfo>::INFO },
    BkeyTypeInfo { name: "whiteout", type_: 1, info: <crate::c::bch_whiteout as TypeInfo>::INFO },
    BkeyTypeInfo { name: "error", type_: 2, info: <crate::c::bch_error as TypeInfo>::INFO },
    BkeyTypeInfo { name: "cookie", type_: 3, info: <crate::c::bch_cookie as TypeInfo>::INFO },
    BkeyTypeInfo { name: "hash_whiteout", type_: 4, info: <crate::c::bch_hash_whiteout as TypeInfo>::INFO },
    BkeyTypeInfo { name: "btree_ptr", type_: 5, info: <crate::c::bch_btree_ptr as TypeInfo>::INFO },
    BkeyTypeInfo { name: "extent", type_: 6, info: <crate::c::bch_extent as TypeInfo>::INFO },
    BkeyTypeInfo { name: "reservation", type_: 7, info: <crate::c::bch_reservation as TypeInfo>::INFO },
    BkeyTypeInfo { name: "inode", type_: 8, info: <crate::c::bch_inode as TypeInfo>::INFO },
    BkeyTypeInfo { name: "inode_generation", type_: 9, info: <crate::c::bch_inode_generation as TypeInfo>::INFO },
    BkeyTypeInfo { name: "dirent", type_: 10, info: <crate::c::bch_dirent as TypeInfo>::INFO },
    BkeyTypeInfo { name: "xattr", type_: 11, info: <crate::c::bch_xattr as TypeInfo>::INFO },
    BkeyTypeInfo { name: "alloc", type_: 12, info: <crate::c::bch_alloc as TypeInfo>::INFO },
    BkeyTypeInfo { name: "quota", type_: 13, info: <crate::c::bch_quota as TypeInfo>::INFO },
    BkeyTypeInfo { name: "stripe", type_: 14, info: <crate::c::bch_stripe as TypeInfo>::INFO },
    BkeyTypeInfo { name: "reflink_p", type_: 15, info: <crate::c::bch_reflink_p as TypeInfo>::INFO },
    BkeyTypeInfo { name: "reflink_v", type_: 16, info: <crate::c::bch_reflink_v as TypeInfo>::INFO },
    BkeyTypeInfo { name: "inline_data", type_: 17, info: <crate::c::bch_inline_data as TypeInfo>::INFO },
    BkeyTypeInfo { name: "btree_ptr_v2", type_: 18, info: <crate::c::bch_btree_ptr_v2 as TypeInfo>::INFO },
    BkeyTypeInfo { name: "indirect_inline_data", type_: 19, info: <crate::c::bch_indirect_inline_data as TypeInfo>::INFO },
    BkeyTypeInfo { name: "alloc_v2", type_: 20, info: <crate::c::bch_alloc_v2 as TypeInfo>::INFO },
    BkeyTypeInfo { name: "subvolume", type_: 21, info: <crate::c::bch_subvolume as TypeInfo>::INFO },
    BkeyTypeInfo { name: "snapshot", type_: 22, info: <crate::c::bch_snapshot as TypeInfo>::INFO },
    BkeyTypeInfo { name: "inode_v2", type_: 23, info: <crate::c::bch_inode_v2 as TypeInfo>::INFO },
    BkeyTypeInfo { name: "alloc_v3", type_: 24, info: <crate::c::bch_alloc_v3 as TypeInfo>::INFO },
    BkeyTypeInfo { name: "set", type_: 25, info: <crate::c::bch_set as TypeInfo>::INFO },
    BkeyTypeInfo { name: "lru", type_: 26, info: <crate::c::bch_lru as TypeInfo>::INFO },
    BkeyTypeInfo { name: "alloc_v4", type_: 27, info: <crate::c::bch_alloc_v4 as TypeInfo>::INFO },
    BkeyTypeInfo { name: "backpointer", type_: 28, info: <crate::c::bch_backpointer as TypeInfo>::INFO },
    BkeyTypeInfo { name: "inode_v3", type_: 29, info: <crate::c::bch_inode_v3 as TypeInfo>::INFO },
    BkeyTypeInfo { name: "bucket_gens", type_: 30, info: <crate::c::bch_bucket_gens as TypeInfo>::INFO },
    BkeyTypeInfo { name: "snapshot_tree", type_: 31, info: <crate::c::bch_snapshot_tree as TypeInfo>::INFO },
    BkeyTypeInfo { name: "logged_op_truncate", type_: 32, info: <crate::c::bch_logged_op_truncate as TypeInfo>::INFO },
    BkeyTypeInfo { name: "logged_op_finsert", type_: 33, info: <crate::c::bch_logged_op_finsert as TypeInfo>::INFO },
    BkeyTypeInfo { name: "accounting", type_: 34, info: <crate::c::bch_accounting as TypeInfo>::INFO },
    BkeyTypeInfo { name: "inode_alloc_cursor", type_: 35, info: <crate::c::bch_inode_alloc_cursor as TypeInfo>::INFO },
    BkeyTypeInfo { name: "extent_whiteout", type_: 36, info: <crate::c::bch_extent_whiteout as TypeInfo>::INFO },
    BkeyTypeInfo { name: "logged_op_stripe_update", type_: 37, info: <crate::c::bch_logged_op_stripe_update as TypeInfo>::INFO },
    BkeyTypeInfo { name: "damage", type_: 38, info: <crate::c::bch_damage as TypeInfo>::INFO },
];

pub fn bkey_val_info(type_: u32) -> Option<&'static StructInfo> {
    BKEY_TYPE_INFO.iter().find(|t| t.type_ == type_).map(|t| t.info)
}

pub fn bkey_type_info_by_name(name: &str) -> Option<&'static BkeyTypeInfo> {
    BKEY_TYPE_INFO.iter().find(|t| t.name == name)
}

// Generated from BITMASK()/LE*_BITMASK() declarations — do not edit

pub static BITMASK_FIELDS: &[BitmaskField] = &[
    BitmaskField { struct_name: "bch_alloc_v3", field: "flags", name: "need_discard", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_alloc_v3", field: "flags", name: "need_inc_gen", lo: 1, hi: 2 },
    BitmaskField { struct_name: "bch_alloc_v4", field: "flags", name: "need_discard", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_alloc_v4", field: "flags", name: "need_inc_gen", lo: 1, hi: 2 },
    BitmaskField { struct_name: "bch_alloc_v4", field: "flags", name: "backpointers_start", lo: 2, hi: 8 },
    BitmaskField { struct_name: "bch_alloc_v4", field: "flags", name: "nr_backpointers", lo: 8, hi: 14 },
    BitmaskField { struct_name: "bch_backpointer", field: "flags", name: "reconcile_phys", lo: 0, hi: 2 },
    BitmaskField { struct_name: "bch_backpointer", field: "flags", name: "erasure_coded", lo: 2, hi: 3 },
    BitmaskField { struct_name: "bch_backpointer", field: "flags", name: "stripe_ptr", lo: 3, hi: 4 },
    BitmaskField { struct_name: "bch_btree_ptr_v2", field: "flags", name: "btree_ptr_range_updated", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_disk_group", field: "flags[0]", name: "bch_group_deleted", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_disk_group", field: "flags[0]", name: "bch_group_data_allowed", lo: 1, hi: 6 },
    BitmaskField { struct_name: "bch_disk_group", field: "flags[0]", name: "bch_group_parent", lo: 6, hi: 24 },
    BitmaskField { struct_name: "bch_inode", field: "bi_flags", name: "inodev1_str_hash", lo: 20, hi: 24 },
    BitmaskField { struct_name: "bch_inode", field: "bi_flags", name: "inodev1_nr_fields", lo: 24, hi: 31 },
    BitmaskField { struct_name: "bch_inode", field: "bi_flags", name: "inodev1_new_varint", lo: 31, hi: 32 },
    BitmaskField { struct_name: "bch_inode_unpacked", field: "bi_flags", name: "inode_str_hash", lo: 20, hi: 24 },
    BitmaskField { struct_name: "bch_inode_v2", field: "bi_flags", name: "inodev2_str_hash", lo: 20, hi: 24 },
    BitmaskField { struct_name: "bch_inode_v2", field: "bi_flags", name: "inodev2_nr_fields", lo: 24, hi: 31 },
    BitmaskField { struct_name: "bch_inode_v3", field: "bi_flags", name: "inodev3_str_hash", lo: 20, hi: 24 },
    BitmaskField { struct_name: "bch_inode_v3", field: "bi_flags", name: "inodev3_nr_fields", lo: 24, hi: 31 },
    BitmaskField { struct_name: "bch_inode_v3", field: "bi_flags", name: "inodev3_fields_start", lo: 31, hi: 36 },
    BitmaskField { struct_name: "bch_inode_v3", field: "bi_flags", name: "inodev3_mode", lo: 36, hi: 52 },
    BitmaskField { struct_name: "bch_member", field: "bucket_size", name: "bucket_size", lo: 0, hi: 16 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "state", lo: 0, hi: 4 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "discard", lo: 14, hi: 15 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "data_allowed", lo: 15, hi: 20 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "group", lo: 20, hi: 28 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "durability", lo: 28, hi: 30 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "freespace_initialized", lo: 30, hi: 31 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "resize_on_mount", lo: 31, hi: 32 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "rotational", lo: 32, hi: 33 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "rotational_set", lo: 33, hi: 34 },
    BitmaskField { struct_name: "bch_member", field: "flags", name: "initialized", lo: 34, hi: 38 },
    BitmaskField { struct_name: "bch_reflink_p", field: "idx_flags", name: "idx", lo: 0, hi: 56 },
    BitmaskField { struct_name: "bch_reflink_p", field: "idx_flags", name: "error", lo: 56, hi: 57 },
    BitmaskField { struct_name: "bch_reflink_p", field: "idx_flags", name: "may_update_options", lo: 57, hi: 58 },
    BitmaskField { struct_name: "bch_sb", field: "block_size", name: "block_size", lo: 0, hi: 16 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "initialized", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "clean", lo: 1, hi: 2 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "csum_type", lo: 2, hi: 8 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "error_action", lo: 8, hi: 12 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "btree_node_size", lo: 12, hi: 28 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "gc_reserve", lo: 28, hi: 33 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "root_reserve", lo: 33, hi: 40 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "meta_csum_type", lo: 40, hi: 44 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "data_csum_type", lo: 44, hi: 48 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "meta_replicas_want", lo: 48, hi: 52 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "data_replicas_want", lo: 52, hi: 56 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "posix_acl", lo: 56, hi: 57 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "usrquota", lo: 57, hi: 58 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "grpquota", lo: 58, hi: 59 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "prjquota", lo: 59, hi: 60 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "has_errors", lo: 60, hi: 61 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "has_topology_errors", lo: 61, hi: 62 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "big_endian", lo: 62, hi: 63 },
    BitmaskField { struct_name: "bch_sb", field: "flags[0]", name: "promote_whole_extents", lo: 63, hi: 64 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "str_hash_type", lo: 0, hi: 4 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "compression_type_lo", lo: 4, hi: 8 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "inode_32bit", lo: 8, hi: 9 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "128_bit_macs", lo: 9, hi: 10 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "encryption_type", lo: 10, hi: 14 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "encoded_extent_max_bits", lo: 14, hi: 20 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "meta_replicas_req", lo: 20, hi: 24 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "data_replicas_req", lo: 24, hi: 28 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "promote_target", lo: 28, hi: 40 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "foreground_target", lo: 40, hi: 52 },
    BitmaskField { struct_name: "bch_sb", field: "flags[1]", name: "background_target", lo: 52, hi: 64 },
    BitmaskField { struct_name: "bch_sb", field: "flags[2]", name: "background_compression_type_lo", lo: 0, hi: 4 },
    BitmaskField { struct_name: "bch_sb", field: "flags[2]", name: "gc_reserve_bytes", lo: 4, hi: 64 },
    BitmaskField { struct_name: "bch_sb", field: "flags[3]", name: "erasure_code", lo: 0, hi: 16 },
    BitmaskField { struct_name: "bch_sb", field: "flags[3]", name: "metadata_target", lo: 16, hi: 28 },
    BitmaskField { struct_name: "bch_sb", field: "flags[3]", name: "shard_inums", lo: 28, hi: 29 },
    BitmaskField { struct_name: "bch_sb", field: "flags[3]", name: "journal_flush_delay", lo: 30, hi: 62 },
    BitmaskField { struct_name: "bch_sb", field: "flags[3]", name: "journal_flush_disabled", lo: 62, hi: 63 },
    BitmaskField { struct_name: "bch_sb", field: "flags[3]", name: "multi_device", lo: 63, hi: 64 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "journal_reclaim_delay", lo: 0, hi: 32 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "journal_transaction_names", lo: 32, hi: 33 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "nocow", lo: 33, hi: 34 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "write_buffer_size", lo: 34, hi: 54 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "version_upgrade", lo: 54, hi: 56 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "compression_type_hi", lo: 56, hi: 60 },
    BitmaskField { struct_name: "bch_sb", field: "flags[4]", name: "background_compression_type_hi", lo: 60, hi: 64 },
    BitmaskField { struct_name: "bch_sb", field: "flags[5]", name: "version_upgrade_complete", lo: 0, hi: 16 },
    BitmaskField { struct_name: "bch_sb", field: "flags[5]", name: "allocator_stuck_timeout", lo: 16, hi: 32 },
    BitmaskField { struct_name: "bch_sb", field: "flags[5]", name: "version_incompat", lo: 32, hi: 48 },
    BitmaskField { struct_name: "bch_sb", field: "flags[5]", name: "version_incompat_allowed", lo: 48, hi: 64 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "shard_inums_nbits", lo: 0, hi: 4 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "write_error_timeout", lo: 4, hi: 14 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "csum_err_retry_nr", lo: 14, hi: 20 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "degraded_action", lo: 20, hi: 22 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "casefold", lo: 22, hi: 23 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "rebalance_ac_only", lo: 23, hi: 24 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "writeback_timeout", lo: 24, hi: 40 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "extent_bp_shift", lo: 40, hi: 48 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "scrub_journal", lo: 48, hi: 50 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "ec_max_data_blocks", lo: 50, hi: 58 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "move_writes_fua", lo: 58, hi: 59 },
    BitmaskField { struct_name: "bch_sb", field: "flags[6]", name: "dirents_sanitized", lo: 59, hi: 60 },
    BitmaskField { struct_name: "bch_sb_field_crypt", field: "flags", name: "bch_crypt_kdf_type", lo: 0, hi: 4 },
    BitmaskField { struct_name: "bch_sb_field_crypt", field: "kdf_flags", name: "bch_kdf_scrypt_n", lo: 0, hi: 16 },
    BitmaskField { struct_name: "bch_sb_field_crypt", field: "kdf_flags", name: "bch_kdf_scrypt_r", lo: 16, hi: 32 },
    BitmaskField { struct_name: "bch_sb_field_crypt", field: "kdf_flags", name: "bch_kdf_scrypt_p", lo: 32, hi: 48 },
    BitmaskField { struct_name: "bch_sb_field_error_entry", field: "v", name: "bch_sb_error_entry_id", lo: 0, hi: 16 },
    BitmaskField { struct_name: "bch_sb_field_error_entry", field: "v", name: "bch_sb_error_entry_nr", lo: 16, hi: 64 },
    BitmaskField { struct_name: "bch_sb_field_ext", field: "flags0", name: "bch_sb_ext_dev_readahead", lo: 0, hi: 20 },
    BitmaskField { struct_name: "bch_sb_field_ext", field: "flags0", name: "bch_sb_ext_ec_stripe_buf_limit", lo: 20, hi: 26 },
    BitmaskField { struct_name: "bch_sb_field_ext", field: "flags0", name: "bch_sb_ext_scrub_max_rewind_secs", lo: 26, hi: 38 },
    BitmaskField { struct_name: "bch_sb_field_ext", field: "flags0", name: "bch_sb_ext_discard_buffer", lo: 38, hi: 42 },
    BitmaskField { struct_name: "bch_sb_field_ext", field: "flags0", name: "bch_sb_ext_btree_cache_shrinker_seeks", lo: 42, hi: 49 },
    BitmaskField { struct_name: "bch_sb_field_ext", field: "flags0", name: "bch_sb_ext_missing_dev_timeout", lo: 49, hi: 61 },
    BitmaskField { struct_name: "bch_snapshot", field: "flags", name: "will_delete_obsolete", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_snapshot", field: "flags", name: "subvol_obsolete", lo: 1, hi: 2 },
    BitmaskField { struct_name: "bch_snapshot", field: "flags", name: "deleted_obsolete", lo: 2, hi: 3 },
    BitmaskField { struct_name: "bch_snapshot", field: "flags", name: "no_keys_obsolete", lo: 3, hi: 4 },
    BitmaskField { struct_name: "bch_subvolume", field: "flags", name: "ro", lo: 0, hi: 1 },
    BitmaskField { struct_name: "bch_subvolume", field: "flags", name: "snap", lo: 1, hi: 2 },
    BitmaskField { struct_name: "bch_subvolume", field: "flags", name: "unlinked_obsolete", lo: 2, hi: 3 },
    BitmaskField { struct_name: "bset", field: "flags", name: "csum_type", lo: 0, hi: 4 },
    BitmaskField { struct_name: "bset", field: "flags", name: "big_endian", lo: 4, hi: 5 },
    BitmaskField { struct_name: "bset", field: "flags", name: "separate_whiteouts", lo: 5, hi: 6 },
    BitmaskField { struct_name: "bset", field: "flags", name: "offset", lo: 16, hi: 32 },
    BitmaskField { struct_name: "btree_node", field: "flags", name: "id_lo", lo: 0, hi: 4 },
    BitmaskField { struct_name: "btree_node", field: "flags", name: "level", lo: 4, hi: 8 },
    BitmaskField { struct_name: "btree_node", field: "flags", name: "new_extent_overwrite", lo: 8, hi: 9 },
    BitmaskField { struct_name: "btree_node", field: "flags", name: "id_hi", lo: 9, hi: 25 },
    BitmaskField { struct_name: "btree_node", field: "flags", name: "seq", lo: 32, hi: 64 },
    BitmaskField { struct_name: "jset", field: "flags", name: "csum_type", lo: 0, hi: 4 },
    BitmaskField { struct_name: "jset", field: "flags", name: "big_endian", lo: 4, hi: 5 },
    BitmaskField { struct_name: "jset", field: "flags", name: "no_flush", lo: 5, hi: 6 },
    BitmaskField { struct_name: "jset", field: "flags", name: "has_overwrites", lo: 6, hi: 7 },
    BitmaskField { struct_name: "recovery_pass_entry", field: "flags", name: "bch_recovery_pass_no_ratelimit", lo: 0, hi: 1 },
];

impl crate::c::bch_alloc_v3 {
    /// BCH_ALLOC_V3_NEED_DISCARD: bits 0..1 of flags
    #[inline]
    pub fn need_discard(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_need_discard(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 0) | ((v as u64) << 0);
        self.flags = (f as u32).to_le();
    }
    /// BCH_ALLOC_V3_NEED_INC_GEN: bits 1..2 of flags
    #[inline]
    pub fn need_inc_gen(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 1 & 1 != 0
    }
    #[inline]
    pub fn set_need_inc_gen(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 1) | ((v as u64) << 1);
        self.flags = (f as u32).to_le();
    }
}

impl crate::c::bch_alloc_v4 {
    /// BCH_ALLOC_V4_NEED_DISCARD: bits 0..1 of flags
    #[inline]
    pub fn need_discard(&self) -> bool {
        (self.flags as u64) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_need_discard(&mut self, v: bool) {
        let f = (self.flags as u64) & !(1 << 0) | ((v as u64) << 0);
        self.flags = f as _;
    }
    /// BCH_ALLOC_V4_NEED_INC_GEN: bits 1..2 of flags
    #[inline]
    pub fn need_inc_gen(&self) -> bool {
        (self.flags as u64) >> 1 & 1 != 0
    }
    #[inline]
    pub fn set_need_inc_gen(&mut self, v: bool) {
        let f = (self.flags as u64) & !(1 << 1) | ((v as u64) << 1);
        self.flags = f as _;
    }
    /// BCH_ALLOC_V4_BACKPOINTERS_START: bits 2..8 of flags
    #[inline]
    pub fn backpointers_start(&self) -> u64 {
        (self.flags as u64) >> 2 & 0x3f
    }
    #[inline]
    pub fn set_backpointers_start(&mut self, v: u64) {
        let f = (self.flags as u64) & !(0x3f << 2) | ((v & 0x3f) << 2);
        self.flags = f as _;
    }
    /// BCH_ALLOC_V4_NR_BACKPOINTERS: bits 8..14 of flags
    #[inline]
    pub fn nr_backpointers(&self) -> u64 {
        (self.flags as u64) >> 8 & 0x3f
    }
    #[inline]
    pub fn set_nr_backpointers(&mut self, v: u64) {
        let f = (self.flags as u64) & !(0x3f << 8) | ((v & 0x3f) << 8);
        self.flags = f as _;
    }
}

impl crate::c::bch_backpointer {
    /// BACKPOINTER_RECONCILE_PHYS: bits 0..2 of flags
    #[inline]
    pub fn reconcile_phys(&self) -> u64 {
        (self.flags as u64) >> 0 & 0x3
    }
    #[inline]
    pub fn set_reconcile_phys(&mut self, v: u64) {
        let f = (self.flags as u64) & !(0x3 << 0) | ((v & 0x3) << 0);
        self.flags = f as _;
    }
    /// BACKPOINTER_ERASURE_CODED: bits 2..3 of flags
    #[inline]
    pub fn erasure_coded(&self) -> bool {
        (self.flags as u64) >> 2 & 1 != 0
    }
    #[inline]
    pub fn set_erasure_coded(&mut self, v: bool) {
        let f = (self.flags as u64) & !(1 << 2) | ((v as u64) << 2);
        self.flags = f as _;
    }
    /// BACKPOINTER_STRIPE_PTR: bits 3..4 of flags
    #[inline]
    pub fn stripe_ptr(&self) -> bool {
        (self.flags as u64) >> 3 & 1 != 0
    }
    #[inline]
    pub fn set_stripe_ptr(&mut self, v: bool) {
        let f = (self.flags as u64) & !(1 << 3) | ((v as u64) << 3);
        self.flags = f as _;
    }
}

impl crate::c::bch_btree_ptr_v2 {
    /// BTREE_PTR_RANGE_UPDATED: bits 0..1 of flags
    #[inline]
    pub fn btree_ptr_range_updated(&self) -> bool {
        (u16::from_le(self.flags) as u64) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_btree_ptr_range_updated(&mut self, v: bool) {
        let f = (u16::from_le(self.flags) as u64) & !(1 << 0) | ((v as u64) << 0);
        self.flags = (f as u16).to_le();
    }
}

impl crate::c::bch_disk_group {
    /// BCH_GROUP_DELETED: bits 0..1 of flags[0]
    #[inline]
    pub fn bch_group_deleted(&self) -> bool {
        u64::from_le(self.flags[0]) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_bch_group_deleted(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 0) | ((v as u64) << 0);
        self.flags[0] = f.to_le();
    }
    /// BCH_GROUP_DATA_ALLOWED: bits 1..6 of flags[0]
    #[inline]
    pub fn bch_group_data_allowed(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 1 & 0x1f
    }
    #[inline]
    pub fn set_bch_group_data_allowed(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0x1f << 1) | ((v & 0x1f) << 1);
        self.flags[0] = f.to_le();
    }
    /// BCH_GROUP_PARENT: bits 6..24 of flags[0]
    #[inline]
    pub fn bch_group_parent(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 6 & 0x3ffff
    }
    #[inline]
    pub fn set_bch_group_parent(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0x3ffff << 6) | ((v & 0x3ffff) << 6);
        self.flags[0] = f.to_le();
    }
}

impl crate::c::bch_inode {
    /// INODEv1_STR_HASH: bits 20..24 of bi_flags
    #[inline]
    pub fn inodev1_str_hash(&self) -> u64 {
        (u32::from_le(self.bi_flags) as u64) >> 20 & 0xf
    }
    #[inline]
    pub fn set_inodev1_str_hash(&mut self, v: u64) {
        let f = (u32::from_le(self.bi_flags) as u64) & !(0xf << 20) | ((v & 0xf) << 20);
        self.bi_flags = (f as u32).to_le();
    }
    /// INODEv1_NR_FIELDS: bits 24..31 of bi_flags
    #[inline]
    pub fn inodev1_nr_fields(&self) -> u64 {
        (u32::from_le(self.bi_flags) as u64) >> 24 & 0x7f
    }
    #[inline]
    pub fn set_inodev1_nr_fields(&mut self, v: u64) {
        let f = (u32::from_le(self.bi_flags) as u64) & !(0x7f << 24) | ((v & 0x7f) << 24);
        self.bi_flags = (f as u32).to_le();
    }
    /// INODEv1_NEW_VARINT: bits 31..32 of bi_flags
    #[inline]
    pub fn inodev1_new_varint(&self) -> bool {
        (u32::from_le(self.bi_flags) as u64) >> 31 & 1 != 0
    }
    #[inline]
    pub fn set_inodev1_new_varint(&mut self, v: bool) {
        let f = (u32::from_le(self.bi_flags) as u64) & !(1 << 31) | ((v as u64) << 31);
        self.bi_flags = (f as u32).to_le();
    }
}

impl crate::c::bch_inode_unpacked {
    /// INODE_STR_HASH: bits 20..24 of bi_flags
    #[inline]
    pub fn inode_str_hash(&self) -> u64 {
        (self.bi_flags as u64) >> 20 & 0xf
    }
    #[inline]
    pub fn set_inode_str_hash(&mut self, v: u64) {
        let f = (self.bi_flags as u64) & !(0xf << 20) | ((v & 0xf) << 20);
        self.bi_flags = f as _;
    }
}

impl crate::c::bch_inode_v2 {
    /// INODEv2_STR_HASH: bits 20..24 of bi_flags
    #[inline]
    pub fn inodev2_str_hash(&self) -> u64 {
        u64::from_le(self.bi_flags) >> 20 & 0xf
    }
    #[inline]
    pub fn set_inodev2_str_hash(&mut self, v: u64) {
        let f = u64::from_le(self.bi_flags) & !(0xf << 20) | ((v & 0xf) << 20);
        self.bi_flags = f.to_le();
    }
    /// INODEv2_NR_FIELDS: bits 24..31 of bi_flags
    #[inline]
    pub fn inodev2_nr_fields(&self) -> u64 {
        u64::from_le(self.bi_flags) >> 24 & 0x7f
    }
    #[inline]
    pub fn set_inodev2_nr_fields(&mut self, v: u64) {
        let f = u64::from_le(self.bi_flags) & !(0x7f << 24) | ((v & 0x7f) << 24);
        self.bi_flags = f.to_le();
    }
}

impl crate::c::bch_inode_v3 {
    /// INODEv3_STR_HASH: bits 20..24 of bi_flags
    #[inline]
    pub fn inodev3_str_hash(&self) -> u64 {
        u64::from_le(self.bi_flags) >> 20 & 0xf
    }
    #[inline]
    pub fn set_inodev3_str_hash(&mut self, v: u64) {
        let f = u64::from_le(self.bi_flags) & !(0xf << 20) | ((v & 0xf) << 20);
        self.bi_flags = f.to_le();
    }
    /// INODEv3_NR_FIELDS: bits 24..31 of bi_flags
    #[inline]
    pub fn inodev3_nr_fields(&self) -> u64 {
        u64::from_le(self.bi_flags) >> 24 & 0x7f
    }
    #[inline]
    pub fn set_inodev3_nr_fields(&mut self, v: u64) {
        let f = u64::from_le(self.bi_flags) & !(0x7f << 24) | ((v & 0x7f) << 24);
        self.bi_flags = f.to_le();
    }
    /// INODEv3_FIELDS_START: bits 31..36 of bi_flags
    #[inline]
    pub fn inodev3_fields_start(&self) -> u64 {
        u64::from_le(self.bi_flags) >> 31 & 0x1f
    }
    #[inline]
    pub fn set_inodev3_fields_start(&mut self, v: u64) {
        let f = u64::from_le(self.bi_flags) & !(0x1f << 31) | ((v & 0x1f) << 31);
        self.bi_flags = f.to_le();
    }
    /// INODEv3_MODE: bits 36..52 of bi_flags
    #[inline]
    pub fn inodev3_mode(&self) -> u64 {
        u64::from_le(self.bi_flags) >> 36 & 0xffff
    }
    #[inline]
    pub fn set_inodev3_mode(&mut self, v: u64) {
        let f = u64::from_le(self.bi_flags) & !(0xffff << 36) | ((v & 0xffff) << 36);
        self.bi_flags = f.to_le();
    }
}

impl crate::c::bch_member {
    /// BCH_MEMBER_BUCKET_SIZE: bits 0..16 of bucket_size
    #[inline]
    pub fn bucket_size(&self) -> u64 {
        (u16::from_le(self.bucket_size) as u64) >> 0 & 0xffff
    }
    #[inline]
    pub fn set_bucket_size(&mut self, v: u64) {
        let f = (u16::from_le(self.bucket_size) as u64) & !(0xffff << 0) | ((v & 0xffff) << 0);
        self.bucket_size = (f as u16).to_le();
    }
    /// BCH_MEMBER_STATE: bits 0..4 of flags
    #[inline]
    pub fn state(&self) -> u64 {
        u64::from_le(self.flags) >> 0 & 0xf
    }
    #[inline]
    pub fn set_state(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_DISCARD: bits 14..15 of flags
    #[inline]
    pub fn discard(&self) -> bool {
        u64::from_le(self.flags) >> 14 & 1 != 0
    }
    #[inline]
    pub fn set_discard(&mut self, v: bool) {
        let f = u64::from_le(self.flags) & !(1 << 14) | ((v as u64) << 14);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_DATA_ALLOWED: bits 15..20 of flags
    #[inline]
    pub fn data_allowed(&self) -> u64 {
        u64::from_le(self.flags) >> 15 & 0x1f
    }
    #[inline]
    pub fn set_data_allowed(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0x1f << 15) | ((v & 0x1f) << 15);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_GROUP: bits 20..28 of flags
    #[inline]
    pub fn group(&self) -> u64 {
        u64::from_le(self.flags) >> 20 & 0xff
    }
    #[inline]
    pub fn set_group(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xff << 20) | ((v & 0xff) << 20);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_DURABILITY: bits 28..30 of flags
    #[inline]
    pub fn durability(&self) -> u64 {
        u64::from_le(self.flags) >> 28 & 0x3
    }
    #[inline]
    pub fn set_durability(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0x3 << 28) | ((v & 0x3) << 28);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_FREESPACE_INITIALIZED: bits 30..31 of flags
    #[inline]
    pub fn freespace_initialized(&self) -> bool {
        u64::from_le(self.flags) >> 30 & 1 != 0
    }
    #[inline]
    pub fn set_freespace_initialized(&mut self, v: bool) {
        let f = u64::from_le(self.flags) & !(1 << 30) | ((v as u64) << 30);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_RESIZE_ON_MOUNT: bits 31..32 of flags
    #[inline]
    pub fn resize_on_mount(&self) -> bool {
        u64::from_le(self.flags) >> 31 & 1 != 0
    }
    #[inline]
    pub fn set_resize_on_mount(&mut self, v: bool) {
        let f = u64::from_le(self.flags) & !(1 << 31) | ((v as u64) << 31);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_ROTATIONAL: bits 32..33 of flags
    #[inline]
    pub fn rotational(&self) -> bool {
        u64::from_le(self.flags) >> 32 & 1 != 0
    }
    #[inline]
    pub fn set_rotational(&mut self, v: bool) {
        let f = u64::from_le(self.flags) & !(1 << 32) | ((v as u64) << 32);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_ROTATIONAL_SET: bits 33..34 of flags
    #[inline]
    pub fn rotational_set(&self) -> bool {
        u64::from_le(self.flags) >> 33 & 1 != 0
    }
    #[inline]
    pub fn set_rotational_set(&mut self, v: bool) {
        let f = u64::from_le(self.flags) & !(1 << 33) | ((v as u64) << 33);
        self.flags = f.to_le();
    }
    /// BCH_MEMBER_INITIALIZED: bits 34..38 of flags
    #[inline]
    pub fn initialized(&self) -> u64 {
        u64::from_le(self.flags) >> 34 & 0xf
    }
    #[inline]
    pub fn set_initialized(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xf << 34) | ((v & 0xf) << 34);
        self.flags = f.to_le();
    }
}

impl crate::c::bch_reflink_p {
    /// REFLINK_P_IDX: bits 0..56 of idx_flags
    #[inline]
    pub fn idx(&self) -> u64 {
        u64::from_le(self.idx_flags) >> 0 & 0xffffffffffffff
    }
    #[inline]
    pub fn set_idx(&mut self, v: u64) {
        let f = u64::from_le(self.idx_flags) & !(0xffffffffffffff << 0) | ((v & 0xffffffffffffff) << 0);
        self.idx_flags = f.to_le();
    }
    /// REFLINK_P_ERROR: bits 56..57 of idx_flags
    #[inline]
    pub fn error(&self) -> bool {
        u64::from_le(self.idx_flags) >> 56 & 1 != 0
    }
    #[inline]
    pub fn set_error(&mut self, v: bool) {
        let f = u64::from_le(self.idx_flags) & !(1 << 56) | ((v as u64) << 56);
        self.idx_flags = f.to_le();
    }
    /// REFLINK_P_MAY_UPDATE_OPTIONS: bits 57..58 of idx_flags
    #[inline]
    pub fn may_update_options(&self) -> bool {
        u64::from_le(self.idx_flags) >> 57 & 1 != 0
    }
    #[inline]
    pub fn set_may_update_options(&mut self, v: bool) {
        let f = u64::from_le(self.idx_flags) & !(1 << 57) | ((v as u64) << 57);
        self.idx_flags = f.to_le();
    }
}

impl crate::c::bch_sb {
    /// BCH_SB_BLOCK_SIZE: bits 0..16 of block_size
    #[inline]
    pub fn block_size(&self) -> u64 {
        (u16::from_le(self.block_size) as u64) >> 0 & 0xffff
    }
    #[inline]
    pub fn set_block_size(&mut self, v: u64) {
        let f = (u16::from_le(self.block_size) as u64) & !(0xffff << 0) | ((v & 0xffff) << 0);
        self.block_size = (f as u16).to_le();
    }
    /// BCH_SB_INITIALIZED: bits 0..1 of flags[0]
    #[inline]
    pub fn initialized(&self) -> bool {
        u64::from_le(self.flags[0]) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_initialized(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 0) | ((v as u64) << 0);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_CLEAN: bits 1..2 of flags[0]
    #[inline]
    pub fn clean(&self) -> bool {
        u64::from_le(self.flags[0]) >> 1 & 1 != 0
    }
    #[inline]
    pub fn set_clean(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 1) | ((v as u64) << 1);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_CSUM_TYPE: bits 2..8 of flags[0]
    #[inline]
    pub fn csum_type(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 2 & 0x3f
    }
    #[inline]
    pub fn set_csum_type(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0x3f << 2) | ((v & 0x3f) << 2);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_ERROR_ACTION: bits 8..12 of flags[0]
    #[inline]
    pub fn error_action(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 8 & 0xf
    }
    #[inline]
    pub fn set_error_action(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0xf << 8) | ((v & 0xf) << 8);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_BTREE_NODE_SIZE: bits 12..28 of flags[0]
    #[inline]
    pub fn btree_node_size(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 12 & 0xffff
    }
    #[inline]
    pub fn set_btree_node_size(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0xffff << 12) | ((v & 0xffff) << 12);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_GC_RESERVE: bits 28..33 of flags[0]
    #[inline]
    pub fn gc_reserve(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 28 & 0x1f
    }
    #[inline]
    pub fn set_gc_reserve(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0x1f << 28) | ((v & 0x1f) << 28);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_ROOT_RESERVE: bits 33..40 of flags[0]
    #[inline]
    pub fn root_reserve(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 33 & 0x7f
    }
    #[inline]
    pub fn set_root_reserve(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0x7f << 33) | ((v & 0x7f) << 33);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_META_CSUM_TYPE: bits 40..44 of flags[0]
    #[inline]
    pub fn meta_csum_type(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 40 & 0xf
    }
    #[inline]
    pub fn set_meta_csum_type(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0xf << 40) | ((v & 0xf) << 40);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_DATA_CSUM_TYPE: bits 44..48 of flags[0]
    #[inline]
    pub fn data_csum_type(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 44 & 0xf
    }
    #[inline]
    pub fn set_data_csum_type(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0xf << 44) | ((v & 0xf) << 44);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_META_REPLICAS_WANT: bits 48..52 of flags[0]
    #[inline]
    pub fn meta_replicas_want(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 48 & 0xf
    }
    #[inline]
    pub fn set_meta_replicas_want(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0xf << 48) | ((v & 0xf) << 48);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_DATA_REPLICAS_WANT: bits 52..56 of flags[0]
    #[inline]
    pub fn data_replicas_want(&self) -> u64 {
        u64::from_le(self.flags[0]) >> 52 & 0xf
    }
    #[inline]
    pub fn set_data_replicas_want(&mut self, v: u64) {
        let f = u64::from_le(self.flags[0]) & !(0xf << 52) | ((v & 0xf) << 52);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_POSIX_ACL: bits 56..57 of flags[0]
    #[inline]
    pub fn posix_acl(&self) -> bool {
        u64::from_le(self.flags[0]) >> 56 & 1 != 0
    }
    #[inline]
    pub fn set_posix_acl(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 56) | ((v as u64) << 56);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_USRQUOTA: bits 57..58 of flags[0]
    #[inline]
    pub fn usrquota(&self) -> bool {
        u64::from_le(self.flags[0]) >> 57 & 1 != 0
    }
    #[inline]
    pub fn set_usrquota(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 57) | ((v as u64) << 57);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_GRPQUOTA: bits 58..59 of flags[0]
    #[inline]
    pub fn grpquota(&self) -> bool {
        u64::from_le(self.flags[0]) >> 58 & 1 != 0
    }
    #[inline]
    pub fn set_grpquota(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 58) | ((v as u64) << 58);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_PRJQUOTA: bits 59..60 of flags[0]
    #[inline]
    pub fn prjquota(&self) -> bool {
        u64::from_le(self.flags[0]) >> 59 & 1 != 0
    }
    #[inline]
    pub fn set_prjquota(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 59) | ((v as u64) << 59);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_HAS_ERRORS: bits 60..61 of flags[0]
    #[inline]
    pub fn has_errors(&self) -> bool {
        u64::from_le(self.flags[0]) >> 60 & 1 != 0
    }
    #[inline]
    pub fn set_has_errors(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 60) | ((v as u64) << 60);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_HAS_TOPOLOGY_ERRORS: bits 61..62 of flags[0]
    #[inline]
    pub fn has_topology_errors(&self) -> bool {
        u64::from_le(self.flags[0]) >> 61 & 1 != 0
    }
    #[inline]
    pub fn set_has_topology_errors(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 61) | ((v as u64) << 61);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_BIG_ENDIAN: bits 62..63 of flags[0]
    #[inline]
    pub fn big_endian(&self) -> bool {
        u64::from_le(self.flags[0]) >> 62 & 1 != 0
    }
    #[inline]
    pub fn set_big_endian(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 62) | ((v as u64) << 62);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_PROMOTE_WHOLE_EXTENTS: bits 63..64 of flags[0]
    #[inline]
    pub fn promote_whole_extents(&self) -> bool {
        u64::from_le(self.flags[0]) >> 63 & 1 != 0
    }
    #[inline]
    pub fn set_promote_whole_extents(&mut self, v: bool) {
        let f = u64::from_le(self.flags[0]) & !(1 << 63) | ((v as u64) << 63);
        self.flags[0] = f.to_le();
    }
    /// BCH_SB_STR_HASH_TYPE: bits 0..4 of flags[1]
    #[inline]
    pub fn str_hash_type(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 0 & 0xf
    }
    #[inline]
    pub fn set_str_hash_type(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_COMPRESSION_TYPE_LO: bits 4..8 of flags[1]
    #[inline]
    pub fn compression_type_lo(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 4 & 0xf
    }
    #[inline]
    pub fn set_compression_type_lo(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xf << 4) | ((v & 0xf) << 4);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_INODE_32BIT: bits 8..9 of flags[1]
    #[inline]
    pub fn inode_32bit(&self) -> bool {
        u64::from_le(self.flags[1]) >> 8 & 1 != 0
    }
    #[inline]
    pub fn set_inode_32bit(&mut self, v: bool) {
        let f = u64::from_le(self.flags[1]) & !(1 << 8) | ((v as u64) << 8);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_128_BIT_MACS: bits 9..10 of flags[1]
    #[inline]
    pub fn _128_bit_macs(&self) -> bool {
        u64::from_le(self.flags[1]) >> 9 & 1 != 0
    }
    #[inline]
    pub fn set_128_bit_macs(&mut self, v: bool) {
        let f = u64::from_le(self.flags[1]) & !(1 << 9) | ((v as u64) << 9);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_ENCRYPTION_TYPE: bits 10..14 of flags[1]
    #[inline]
    pub fn encryption_type(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 10 & 0xf
    }
    #[inline]
    pub fn set_encryption_type(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xf << 10) | ((v & 0xf) << 10);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_ENCODED_EXTENT_MAX_BITS: bits 14..20 of flags[1]
    #[inline]
    pub fn encoded_extent_max_bits(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 14 & 0x3f
    }
    #[inline]
    pub fn set_encoded_extent_max_bits(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0x3f << 14) | ((v & 0x3f) << 14);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_META_REPLICAS_REQ: bits 20..24 of flags[1]
    #[inline]
    pub fn meta_replicas_req(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 20 & 0xf
    }
    #[inline]
    pub fn set_meta_replicas_req(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xf << 20) | ((v & 0xf) << 20);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_DATA_REPLICAS_REQ: bits 24..28 of flags[1]
    #[inline]
    pub fn data_replicas_req(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 24 & 0xf
    }
    #[inline]
    pub fn set_data_replicas_req(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xf << 24) | ((v & 0xf) << 24);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_PROMOTE_TARGET: bits 28..40 of flags[1]
    #[inline]
    pub fn promote_target(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 28 & 0xfff
    }
    #[inline]
    pub fn set_promote_target(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xfff << 28) | ((v & 0xfff) << 28);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_FOREGROUND_TARGET: bits 40..52 of flags[1]
    #[inline]
    pub fn foreground_target(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 40 & 0xfff
    }
    #[inline]
    pub fn set_foreground_target(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xfff << 40) | ((v & 0xfff) << 40);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_BACKGROUND_TARGET: bits 52..64 of flags[1]
    #[inline]
    pub fn background_target(&self) -> u64 {
        u64::from_le(self.flags[1]) >> 52 & 0xfff
    }
    #[inline]
    pub fn set_background_target(&mut self, v: u64) {
        let f = u64::from_le(self.flags[1]) & !(0xfff << 52) | ((v & 0xfff) << 52);
        self.flags[1] = f.to_le();
    }
    /// BCH_SB_BACKGROUND_COMPRESSION_TYPE_LO: bits 0..4 of flags[2]
    #[inline]
    pub fn background_compression_type_lo(&self) -> u64 {
        u64::from_le(self.flags[2]) >> 0 & 0xf
    }
    #[inline]
    pub fn set_background_compression_type_lo(&mut self, v: u64) {
        let f = u64::from_le(self.flags[2]) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags[2] = f.to_le();
    }
    /// BCH_SB_GC_RESERVE_BYTES: bits 4..64 of flags[2]
    #[inline]
    pub fn gc_reserve_bytes(&self) -> u64 {
        u64::from_le(self.flags[2]) >> 4 & 0xfffffffffffffff
    }
    #[inline]
    pub fn set_gc_reserve_bytes(&mut self, v: u64) {
        let f = u64::from_le(self.flags[2]) & !(0xfffffffffffffff << 4) | ((v & 0xfffffffffffffff) << 4);
        self.flags[2] = f.to_le();
    }
    /// BCH_SB_ERASURE_CODE: bits 0..16 of flags[3]
    #[inline]
    pub fn erasure_code(&self) -> u64 {
        u64::from_le(self.flags[3]) >> 0 & 0xffff
    }
    #[inline]
    pub fn set_erasure_code(&mut self, v: u64) {
        let f = u64::from_le(self.flags[3]) & !(0xffff << 0) | ((v & 0xffff) << 0);
        self.flags[3] = f.to_le();
    }
    /// BCH_SB_METADATA_TARGET: bits 16..28 of flags[3]
    #[inline]
    pub fn metadata_target(&self) -> u64 {
        u64::from_le(self.flags[3]) >> 16 & 0xfff
    }
    #[inline]
    pub fn set_metadata_target(&mut self, v: u64) {
        let f = u64::from_le(self.flags[3]) & !(0xfff << 16) | ((v & 0xfff) << 16);
        self.flags[3] = f.to_le();
    }
    /// BCH_SB_SHARD_INUMS: bits 28..29 of flags[3]
    #[inline]
    pub fn shard_inums(&self) -> bool {
        u64::from_le(self.flags[3]) >> 28 & 1 != 0
    }
    #[inline]
    pub fn set_shard_inums(&mut self, v: bool) {
        let f = u64::from_le(self.flags[3]) & !(1 << 28) | ((v as u64) << 28);
        self.flags[3] = f.to_le();
    }
    /// BCH_SB_JOURNAL_FLUSH_DELAY: bits 30..62 of flags[3]
    #[inline]
    pub fn journal_flush_delay(&self) -> u64 {
        u64::from_le(self.flags[3]) >> 30 & 0xffffffff
    }
    #[inline]
    pub fn set_journal_flush_delay(&mut self, v: u64) {
        let f = u64::from_le(self.flags[3]) & !(0xffffffff << 30) | ((v & 0xffffffff) << 30);
        self.flags[3] = f.to_le();
    }
    /// BCH_SB_JOURNAL_FLUSH_DISABLED: bits 62..63 of flags[3]
    #[inline]
    pub fn journal_flush_disabled(&self) -> bool {
        u64::from_le(self.flags[3]) >> 62 & 1 != 0
    }
    #[inline]
    pub fn set_journal_flush_disabled(&mut self, v: bool) {
        let f = u64::from_le(self.flags[3]) & !(1 << 62) | ((v as u64) << 62);
        self.flags[3] = f.to_le();
    }
    /// BCH_SB_MULTI_DEVICE: bits 63..64 of flags[3]
    #[inline]
    pub fn multi_device(&self) -> bool {
        u64::from_le(self.flags[3]) >> 63 & 1 != 0
    }
    #[inline]
    pub fn set_multi_device(&mut self, v: bool) {
        let f = u64::from_le(self.flags[3]) & !(1 << 63) | ((v as u64) << 63);
        self.flags[3] = f.to_le();
    }
    /// BCH_SB_JOURNAL_RECLAIM_DELAY: bits 0..32 of flags[4]
    #[inline]
    pub fn journal_reclaim_delay(&self) -> u64 {
        u64::from_le(self.flags[4]) >> 0 & 0xffffffff
    }
    #[inline]
    pub fn set_journal_reclaim_delay(&mut self, v: u64) {
        let f = u64::from_le(self.flags[4]) & !(0xffffffff << 0) | ((v & 0xffffffff) << 0);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_JOURNAL_TRANSACTION_NAMES: bits 32..33 of flags[4]
    #[inline]
    pub fn journal_transaction_names(&self) -> bool {
        u64::from_le(self.flags[4]) >> 32 & 1 != 0
    }
    #[inline]
    pub fn set_journal_transaction_names(&mut self, v: bool) {
        let f = u64::from_le(self.flags[4]) & !(1 << 32) | ((v as u64) << 32);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_NOCOW: bits 33..34 of flags[4]
    #[inline]
    pub fn nocow(&self) -> bool {
        u64::from_le(self.flags[4]) >> 33 & 1 != 0
    }
    #[inline]
    pub fn set_nocow(&mut self, v: bool) {
        let f = u64::from_le(self.flags[4]) & !(1 << 33) | ((v as u64) << 33);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_WRITE_BUFFER_SIZE: bits 34..54 of flags[4]
    #[inline]
    pub fn write_buffer_size(&self) -> u64 {
        u64::from_le(self.flags[4]) >> 34 & 0xfffff
    }
    #[inline]
    pub fn set_write_buffer_size(&mut self, v: u64) {
        let f = u64::from_le(self.flags[4]) & !(0xfffff << 34) | ((v & 0xfffff) << 34);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_VERSION_UPGRADE: bits 54..56 of flags[4]
    #[inline]
    pub fn version_upgrade(&self) -> u64 {
        u64::from_le(self.flags[4]) >> 54 & 0x3
    }
    #[inline]
    pub fn set_version_upgrade(&mut self, v: u64) {
        let f = u64::from_le(self.flags[4]) & !(0x3 << 54) | ((v & 0x3) << 54);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_COMPRESSION_TYPE_HI: bits 56..60 of flags[4]
    #[inline]
    pub fn compression_type_hi(&self) -> u64 {
        u64::from_le(self.flags[4]) >> 56 & 0xf
    }
    #[inline]
    pub fn set_compression_type_hi(&mut self, v: u64) {
        let f = u64::from_le(self.flags[4]) & !(0xf << 56) | ((v & 0xf) << 56);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_BACKGROUND_COMPRESSION_TYPE_HI: bits 60..64 of flags[4]
    #[inline]
    pub fn background_compression_type_hi(&self) -> u64 {
        u64::from_le(self.flags[4]) >> 60 & 0xf
    }
    #[inline]
    pub fn set_background_compression_type_hi(&mut self, v: u64) {
        let f = u64::from_le(self.flags[4]) & !(0xf << 60) | ((v & 0xf) << 60);
        self.flags[4] = f.to_le();
    }
    /// BCH_SB_VERSION_UPGRADE_COMPLETE: bits 0..16 of flags[5]
    #[inline]
    pub fn version_upgrade_complete(&self) -> u64 {
        u64::from_le(self.flags[5]) >> 0 & 0xffff
    }
    #[inline]
    pub fn set_version_upgrade_complete(&mut self, v: u64) {
        let f = u64::from_le(self.flags[5]) & !(0xffff << 0) | ((v & 0xffff) << 0);
        self.flags[5] = f.to_le();
    }
    /// BCH_SB_ALLOCATOR_STUCK_TIMEOUT: bits 16..32 of flags[5]
    #[inline]
    pub fn allocator_stuck_timeout(&self) -> u64 {
        u64::from_le(self.flags[5]) >> 16 & 0xffff
    }
    #[inline]
    pub fn set_allocator_stuck_timeout(&mut self, v: u64) {
        let f = u64::from_le(self.flags[5]) & !(0xffff << 16) | ((v & 0xffff) << 16);
        self.flags[5] = f.to_le();
    }
    /// BCH_SB_VERSION_INCOMPAT: bits 32..48 of flags[5]
    #[inline]
    pub fn version_incompat(&self) -> u64 {
        u64::from_le(self.flags[5]) >> 32 & 0xffff
    }
    #[inline]
    pub fn set_version_incompat(&mut self, v: u64) {
        let f = u64::from_le(self.flags[5]) & !(0xffff << 32) | ((v & 0xffff) << 32);
        self.flags[5] = f.to_le();
    }
    /// BCH_SB_VERSION_INCOMPAT_ALLOWED: bits 48..64 of flags[5]
    #[inline]
    pub fn version_incompat_allowed(&self) -> u64 {
        u64::from_le(self.flags[5]) >> 48 & 0xffff
    }
    #[inline]
    pub fn set_version_incompat_allowed(&mut self, v: u64) {
        let f = u64::from_le(self.flags[5]) & !(0xffff << 48) | ((v & 0xffff) << 48);
        self.flags[5] = f.to_le();
    }
    /// BCH_SB_SHARD_INUMS_NBITS: bits 0..4 of flags[6]
    #[inline]
    pub fn shard_inums_nbits(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 0 & 0xf
    }
    #[inline]
    pub fn set_shard_inums_nbits(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_WRITE_ERROR_TIMEOUT: bits 4..14 of flags[6]
    #[inline]
    pub fn write_error_timeout(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 4 & 0x3ff
    }
    #[inline]
    pub fn set_write_error_timeout(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0x3ff << 4) | ((v & 0x3ff) << 4);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_CSUM_ERR_RETRY_NR: bits 14..20 of flags[6]
    #[inline]
    pub fn csum_err_retry_nr(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 14 & 0x3f
    }
    #[inline]
    pub fn set_csum_err_retry_nr(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0x3f << 14) | ((v & 0x3f) << 14);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_DEGRADED_ACTION: bits 20..22 of flags[6]
    #[inline]
    pub fn degraded_action(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 20 & 0x3
    }
    #[inline]
    pub fn set_degraded_action(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0x3 << 20) | ((v & 0x3) << 20);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_CASEFOLD: bits 22..23 of flags[6]
    #[inline]
    pub fn casefold(&self) -> bool {
        u64::from_le(self.flags[6]) >> 22 & 1 != 0
    }
    #[inline]
    pub fn set_casefold(&mut self, v: bool) {
        let f = u64::from_le(self.flags[6]) & !(1 << 22) | ((v as u64) << 22);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_REBALANCE_AC_ONLY: bits 23..24 of flags[6]
    #[inline]
    pub fn rebalance_ac_only(&self) -> bool {
        u64::from_le(self.flags[6]) >> 23 & 1 != 0
    }
    #[inline]
    pub fn set_rebalance_ac_only(&mut self, v: bool) {
        let f = u64::from_le(self.flags[6]) & !(1 << 23) | ((v as u64) << 23);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_WRITEBACK_TIMEOUT: bits 24..40 of flags[6]
    #[inline]
    pub fn writeback_timeout(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 24 & 0xffff
    }
    #[inline]
    pub fn set_writeback_timeout(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0xffff << 24) | ((v & 0xffff) << 24);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_EXTENT_BP_SHIFT: bits 40..48 of flags[6]
    #[inline]
    pub fn extent_bp_shift(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 40 & 0xff
    }
    #[inline]
    pub fn set_extent_bp_shift(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0xff << 40) | ((v & 0xff) << 40);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_SCRUB_JOURNAL: bits 48..50 of flags[6]
    #[inline]
    pub fn scrub_journal(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 48 & 0x3
    }
    #[inline]
    pub fn set_scrub_journal(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0x3 << 48) | ((v & 0x3) << 48);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_EC_MAX_DATA_BLOCKS: bits 50..58 of flags[6]
    #[inline]
    pub fn ec_max_data_blocks(&self) -> u64 {
        u64::from_le(self.flags[6]) >> 50 & 0xff
    }
    #[inline]
    pub fn set_ec_max_data_blocks(&mut self, v: u64) {
        let f = u64::from_le(self.flags[6]) & !(0xff << 50) | ((v & 0xff) << 50);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_MOVE_WRITES_FUA: bits 58..59 of flags[6]
    #[inline]
    pub fn move_writes_fua(&self) -> bool {
        u64::from_le(self.flags[6]) >> 58 & 1 != 0
    }
    #[inline]
    pub fn set_move_writes_fua(&mut self, v: bool) {
        let f = u64::from_le(self.flags[6]) & !(1 << 58) | ((v as u64) << 58);
        self.flags[6] = f.to_le();
    }
    /// BCH_SB_DIRENTS_SANITIZED: bits 59..60 of flags[6]
    #[inline]
    pub fn dirents_sanitized(&self) -> bool {
        u64::from_le(self.flags[6]) >> 59 & 1 != 0
    }
    #[inline]
    pub fn set_dirents_sanitized(&mut self, v: bool) {
        let f = u64::from_le(self.flags[6]) & !(1 << 59) | ((v as u64) << 59);
        self.flags[6] = f.to_le();
    }
}

impl crate::c::bch_sb_field_crypt {
    /// BCH_CRYPT_KDF_TYPE: bits 0..4 of flags
    #[inline]
    pub fn bch_crypt_kdf_type(&self) -> u64 {
        u64::from_le(self.flags) >> 0 & 0xf
    }
    #[inline]
    pub fn set_bch_crypt_kdf_type(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags = f.to_le();
    }
    /// BCH_KDF_SCRYPT_N: bits 0..16 of kdf_flags
    #[inline]
    pub fn bch_kdf_scrypt_n(&self) -> u64 {
        u64::from_le(self.kdf_flags) >> 0 & 0xffff
    }
    #[inline]
    pub fn set_bch_kdf_scrypt_n(&mut self, v: u64) {
        let f = u64::from_le(self.kdf_flags) & !(0xffff << 0) | ((v & 0xffff) << 0);
        self.kdf_flags = f.to_le();
    }
    /// BCH_KDF_SCRYPT_R: bits 16..32 of kdf_flags
    #[inline]
    pub fn bch_kdf_scrypt_r(&self) -> u64 {
        u64::from_le(self.kdf_flags) >> 16 & 0xffff
    }
    #[inline]
    pub fn set_bch_kdf_scrypt_r(&mut self, v: u64) {
        let f = u64::from_le(self.kdf_flags) & !(0xffff << 16) | ((v & 0xffff) << 16);
        self.kdf_flags = f.to_le();
    }
    /// BCH_KDF_SCRYPT_P: bits 32..48 of kdf_flags
    #[inline]
    pub fn bch_kdf_scrypt_p(&self) -> u64 {
        u64::from_le(self.kdf_flags) >> 32 & 0xffff
    }
    #[inline]
    pub fn set_bch_kdf_scrypt_p(&mut self, v: u64) {
        let f = u64::from_le(self.kdf_flags) & !(0xffff << 32) | ((v & 0xffff) << 32);
        self.kdf_flags = f.to_le();
    }
}

impl crate::c::bch_sb_field_error_entry {
    /// BCH_SB_ERROR_ENTRY_ID: bits 0..16 of v
    #[inline]
    pub fn bch_sb_error_entry_id(&self) -> u64 {
        u64::from_le(self.v) >> 0 & 0xffff
    }
    #[inline]
    pub fn set_bch_sb_error_entry_id(&mut self, v: u64) {
        let f = u64::from_le(self.v) & !(0xffff << 0) | ((v & 0xffff) << 0);
        self.v = f.to_le();
    }
    /// BCH_SB_ERROR_ENTRY_NR: bits 16..64 of v
    #[inline]
    pub fn bch_sb_error_entry_nr(&self) -> u64 {
        u64::from_le(self.v) >> 16 & 0xffffffffffff
    }
    #[inline]
    pub fn set_bch_sb_error_entry_nr(&mut self, v: u64) {
        let f = u64::from_le(self.v) & !(0xffffffffffff << 16) | ((v & 0xffffffffffff) << 16);
        self.v = f.to_le();
    }
}

impl crate::c::bch_sb_field_ext {
    /// BCH_SB_EXT_DEV_READAHEAD: bits 0..20 of flags0
    #[inline]
    pub fn bch_sb_ext_dev_readahead(&self) -> u64 {
        u64::from_le(self.flags0) >> 0 & 0xfffff
    }
    #[inline]
    pub fn set_bch_sb_ext_dev_readahead(&mut self, v: u64) {
        let f = u64::from_le(self.flags0) & !(0xfffff << 0) | ((v & 0xfffff) << 0);
        self.flags0 = f.to_le();
    }
    /// BCH_SB_EXT_EC_STRIPE_BUF_LIMIT: bits 20..26 of flags0
    #[inline]
    pub fn bch_sb_ext_ec_stripe_buf_limit(&self) -> u64 {
        u64::from_le(self.flags0) >> 20 & 0x3f
    }
    #[inline]
    pub fn set_bch_sb_ext_ec_stripe_buf_limit(&mut self, v: u64) {
        let f = u64::from_le(self.flags0) & !(0x3f << 20) | ((v & 0x3f) << 20);
        self.flags0 = f.to_le();
    }
    /// BCH_SB_EXT_SCRUB_MAX_REWIND_SECS: bits 26..38 of flags0
    #[inline]
    pub fn bch_sb_ext_scrub_max_rewind_secs(&self) -> u64 {
        u64::from_le(self.flags0) >> 26 & 0xfff
    }
    #[inline]
    pub fn set_bch_sb_ext_scrub_max_rewind_secs(&mut self, v: u64) {
        let f = u64::from_le(self.flags0) & !(0xfff << 26) | ((v & 0xfff) << 26);
        self.flags0 = f.to_le();
    }
    /// BCH_SB_EXT_DISCARD_BUFFER: bits 38..42 of flags0
    #[inline]
    pub fn bch_sb_ext_discard_buffer(&self) -> u64 {
        u64::from_le(self.flags0) >> 38 & 0xf
    }
    #[inline]
    pub fn set_bch_sb_ext_discard_buffer(&mut self, v: u64) {
        let f = u64::from_le(self.flags0) & !(0xf << 38) | ((v & 0xf) << 38);
        self.flags0 = f.to_le();
    }
    /// BCH_SB_EXT_BTREE_CACHE_SHRINKER_SEEKS: bits 42..49 of flags0
    #[inline]
    pub fn bch_sb_ext_btree_cache_shrinker_seeks(&self) -> u64 {
        u64::from_le(self.flags0) >> 42 & 0x7f
    }
    #[inline]
    pub fn set_bch_sb_ext_btree_cache_shrinker_seeks(&mut self, v: u64) {
        let f = u64::from_le(self.flags0) & !(0x7f << 42) | ((v & 0x7f) << 42);
        self.flags0 = f.to_le();
    }
    /// BCH_SB_EXT_MISSING_DEV_TIMEOUT: bits 49..61 of flags0
    #[inline]
    pub fn bch_sb_ext_missing_dev_timeout(&self) -> u64 {
        u64::from_le(self.flags0) >> 49 & 0xfff
    }
    #[inline]
    pub fn set_bch_sb_ext_missing_dev_timeout(&mut self, v: u64) {
        let f = u64::from_le(self.flags0) & !(0xfff << 49) | ((v & 0xfff) << 49);
        self.flags0 = f.to_le();
    }
}

impl crate::c::bch_snapshot {
    /// BCH_SNAPSHOT_WILL_DELETE_OBSOLETE: bits 0..1 of flags
    #[inline]
    pub fn will_delete_obsolete(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_will_delete_obsolete(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 0) | ((v as u64) << 0);
        self.flags = (f as u32).to_le();
    }
    /// BCH_SNAPSHOT_SUBVOL_OBSOLETE: bits 1..2 of flags
    #[inline]
    pub fn subvol_obsolete(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 1 & 1 != 0
    }
    #[inline]
    pub fn set_subvol_obsolete(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 1) | ((v as u64) << 1);
        self.flags = (f as u32).to_le();
    }
    /// BCH_SNAPSHOT_DELETED_OBSOLETE: bits 2..3 of flags
    #[inline]
    pub fn deleted_obsolete(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 2 & 1 != 0
    }
    #[inline]
    pub fn set_deleted_obsolete(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 2) | ((v as u64) << 2);
        self.flags = (f as u32).to_le();
    }
    /// BCH_SNAPSHOT_NO_KEYS_OBSOLETE: bits 3..4 of flags
    #[inline]
    pub fn no_keys_obsolete(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 3 & 1 != 0
    }
    #[inline]
    pub fn set_no_keys_obsolete(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 3) | ((v as u64) << 3);
        self.flags = (f as u32).to_le();
    }
}

impl crate::c::bch_subvolume {
    /// BCH_SUBVOLUME_RO: bits 0..1 of flags
    #[inline]
    pub fn ro(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_ro(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 0) | ((v as u64) << 0);
        self.flags = (f as u32).to_le();
    }
    /// BCH_SUBVOLUME_SNAP: bits 1..2 of flags
    #[inline]
    pub fn snap(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 1 & 1 != 0
    }
    #[inline]
    pub fn set_snap(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 1) | ((v as u64) << 1);
        self.flags = (f as u32).to_le();
    }
    /// BCH_SUBVOLUME_UNLINKED_OBSOLETE: bits 2..3 of flags
    #[inline]
    pub fn unlinked_obsolete(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 2 & 1 != 0
    }
    #[inline]
    pub fn set_unlinked_obsolete(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 2) | ((v as u64) << 2);
        self.flags = (f as u32).to_le();
    }
}

impl crate::c::bset {
    /// BSET_CSUM_TYPE: bits 0..4 of flags
    #[inline]
    pub fn csum_type(&self) -> u64 {
        (u32::from_le(self.flags) as u64) >> 0 & 0xf
    }
    #[inline]
    pub fn set_csum_type(&mut self, v: u64) {
        let f = (u32::from_le(self.flags) as u64) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags = (f as u32).to_le();
    }
    /// BSET_BIG_ENDIAN: bits 4..5 of flags
    #[inline]
    pub fn big_endian(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 4 & 1 != 0
    }
    #[inline]
    pub fn set_big_endian(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 4) | ((v as u64) << 4);
        self.flags = (f as u32).to_le();
    }
    /// BSET_SEPARATE_WHITEOUTS: bits 5..6 of flags
    #[inline]
    pub fn separate_whiteouts(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 5 & 1 != 0
    }
    #[inline]
    pub fn set_separate_whiteouts(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 5) | ((v as u64) << 5);
        self.flags = (f as u32).to_le();
    }
    /// BSET_OFFSET: bits 16..32 of flags
    #[inline]
    pub fn offset(&self) -> u64 {
        (u32::from_le(self.flags) as u64) >> 16 & 0xffff
    }
    #[inline]
    pub fn set_offset(&mut self, v: u64) {
        let f = (u32::from_le(self.flags) as u64) & !(0xffff << 16) | ((v & 0xffff) << 16);
        self.flags = (f as u32).to_le();
    }
}

impl crate::c::btree_node {
    /// BTREE_NODE_ID_LO: bits 0..4 of flags
    #[inline]
    pub fn id_lo(&self) -> u64 {
        u64::from_le(self.flags) >> 0 & 0xf
    }
    #[inline]
    pub fn set_id_lo(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags = f.to_le();
    }
    /// BTREE_NODE_LEVEL: bits 4..8 of flags
    #[inline]
    pub fn level(&self) -> u64 {
        u64::from_le(self.flags) >> 4 & 0xf
    }
    #[inline]
    pub fn set_level(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xf << 4) | ((v & 0xf) << 4);
        self.flags = f.to_le();
    }
    /// BTREE_NODE_NEW_EXTENT_OVERWRITE: bits 8..9 of flags
    #[inline]
    pub fn new_extent_overwrite(&self) -> bool {
        u64::from_le(self.flags) >> 8 & 1 != 0
    }
    #[inline]
    pub fn set_new_extent_overwrite(&mut self, v: bool) {
        let f = u64::from_le(self.flags) & !(1 << 8) | ((v as u64) << 8);
        self.flags = f.to_le();
    }
    /// BTREE_NODE_ID_HI: bits 9..25 of flags
    #[inline]
    pub fn id_hi(&self) -> u64 {
        u64::from_le(self.flags) >> 9 & 0xffff
    }
    #[inline]
    pub fn set_id_hi(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xffff << 9) | ((v & 0xffff) << 9);
        self.flags = f.to_le();
    }
    /// BTREE_NODE_SEQ: bits 32..64 of flags
    #[inline]
    pub fn seq(&self) -> u64 {
        u64::from_le(self.flags) >> 32 & 0xffffffff
    }
    #[inline]
    pub fn set_seq(&mut self, v: u64) {
        let f = u64::from_le(self.flags) & !(0xffffffff << 32) | ((v & 0xffffffff) << 32);
        self.flags = f.to_le();
    }
}

impl crate::c::jset {
    /// JSET_CSUM_TYPE: bits 0..4 of flags
    #[inline]
    pub fn csum_type(&self) -> u64 {
        (u32::from_le(self.flags) as u64) >> 0 & 0xf
    }
    #[inline]
    pub fn set_csum_type(&mut self, v: u64) {
        let f = (u32::from_le(self.flags) as u64) & !(0xf << 0) | ((v & 0xf) << 0);
        self.flags = (f as u32).to_le();
    }
    /// JSET_BIG_ENDIAN: bits 4..5 of flags
    #[inline]
    pub fn big_endian(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 4 & 1 != 0
    }
    #[inline]
    pub fn set_big_endian(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 4) | ((v as u64) << 4);
        self.flags = (f as u32).to_le();
    }
    /// JSET_NO_FLUSH: bits 5..6 of flags
    #[inline]
    pub fn no_flush(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 5 & 1 != 0
    }
    #[inline]
    pub fn set_no_flush(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 5) | ((v as u64) << 5);
        self.flags = (f as u32).to_le();
    }
    /// JSET_HAS_OVERWRITES: bits 6..7 of flags
    #[inline]
    pub fn has_overwrites(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 6 & 1 != 0
    }
    #[inline]
    pub fn set_has_overwrites(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 6) | ((v as u64) << 6);
        self.flags = (f as u32).to_le();
    }
}

impl crate::c::recovery_pass_entry {
    /// BCH_RECOVERY_PASS_NO_RATELIMIT: bits 0..1 of flags
    #[inline]
    pub fn bch_recovery_pass_no_ratelimit(&self) -> bool {
        (u32::from_le(self.flags) as u64) >> 0 & 1 != 0
    }
    #[inline]
    pub fn set_bch_recovery_pass_no_ratelimit(&mut self, v: bool) {
        let f = (u32::from_le(self.flags) as u64) & !(1 << 0) | ((v as u64) << 0);
        self.flags = (f as u32).to_le();
    }
}
