Skip to content

Commit f9137eb

Browse files
Fixed bytestring
1 parent bd40b7a commit f9137eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/rfl/ubjson/Reader.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ class Reader {
5959
return _var.val_->as<std::string>();
6060
} else if constexpr (std::is_same<std::remove_cvref_t<T>,
6161
rfl::Bytestring>()) {
62-
if (!_var.val_->is_byte_string()) {
62+
if (!_var.val_->is<std::vector<uint8_t>>()) {
6363
return Error("Could not cast to bytestring.");
6464
}
65-
return rfl::Bytestring(); // TODO
65+
const auto vec = _var.val_->as<std::vector<uint8_t>>();
66+
return rfl::Bytestring(std::bit_cast<const std::byte*>(vec.data()),
67+
vec.size());
6668
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
6769
if (!_var.val_->is_bool()) {
6870
return rfl::Error("Could not cast to boolean.");

0 commit comments

Comments
 (0)