Provided by: libbson-doc_2.2.1-1_all bug

SYNOPSIS

          #include <bson/bson.h>

          typedef struct bson_vector_packed_bit_view_t {
             /*< private >*/
          } bson_vector_packed_bit_view_t;

DESCRIPTION

       bson_vector_packed_bit_view_t  <>  is  a  structure that acts as an opaque reference to a block of memory
       that has been validated as a packed_bit vector.

       It is meant to be passed by value and can be discarded at any time. The contents of the structure  should
       be considered private.

       The bson_t <> MUST be valid for the lifetime of the view and it is an error to modify the bson_t <> while
       using the view.

EXAMPLE

          // Fill a new vector with individual boolean elements
          {
              static const bool bool_values[] = {true, false, true, true, false};
              const size_t bool_values_count = sizeof bool_values / sizeof bool_values[0];

              bson_vector_packed_bit_view_t view;
              BSON_ASSERT (BSON_APPEND_VECTOR_PACKED_BIT_UNINIT (&doc, "from_bool", bool_values_count, &view));
              BSON_ASSERT (bson_vector_packed_bit_view_pack_bool (view, bool_values, bool_values_count, 0));
          }

          // Fill another new vector with packed bytes
          {
              static const uint8_t packed_bytes[] = {0xb0};
              const size_t unused_bits_count = 3;
              const size_t packed_values_count = sizeof packed_bytes * 8 - unused_bits_count;

              bson_vector_packed_bit_view_t view;
              BSON_ASSERT (BSON_APPEND_VECTOR_PACKED_BIT_UNINIT (&doc, "from_packed", packed_values_count, &view));
              BSON_ASSERT (bson_vector_packed_bit_view_write_packed (view, packed_bytes, sizeof packed_bytes, 0));
          }

          // Compare both vectors. They match exactly.
          {
              bson_iter_t from_bool_iter, from_packed_iter;
              BSON_ASSERT (bson_iter_init_find (&from_bool_iter, &doc, "from_bool"));
              BSON_ASSERT (bson_iter_init_find (&from_packed_iter, &doc, "from_packed"));
              BSON_ASSERT (bson_iter_binary_equal (&from_bool_iter, &from_packed_iter));
          }

       See also:
          bson_append_vector_packed_bit_uninit() <>
          bson_vector_packed_bit_const_view_t <>

Author

       MongoDB, Inc

Copyright

       2009-present, MongoDB, Inc.

2.2.1                                             Dec 11, 2025                  BSON_VECTOR_PACKED_BIT_VIEW_T(3)