Add from_bytes helper

This commit is contained in:
Romain Thomas
2026-01-01 06:37:16 +01:00
parent d6a97f0aa7
commit 9ddfcd89ba
2 changed files with 9 additions and 4 deletions
@@ -29,7 +29,11 @@ void create<VectorStream>(nb::module_& m) {
nb::class_<VectorStream, BinaryStream>(m, "VectorStream")
.def_static("from_file", [] (typing::StrOrPath path) {
return VectorStream::from_file(*path.to_string());
})
}, "path"_a)
.def_static("from_bytes", [] (nb::bytes buffer) {
return std::make_unique<VectorStream>(nb::to_vector(buffer));
}, "buffer"_a)
.def_prop_ro("content", [] (VectorStream& self) {
return nb::to_memoryview(self.content());