Skip to content

Commit 170aad9

Browse files
committed
fix: convert Rust buffer to Python bytes in RemoteFileReader
1 parent b20fa57 commit 170aad9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/multistorageclient/file.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def read(self, size: int = -1) -> bytes:
114114
data = self._storage_client.read(
115115
self._remote_path, byte_range=bytes_range, check_source_version=self._check_source_version
116116
)
117+
# If the storage client is using the Rust client, convert the Rust bytes-like buffer to Python bytes
118+
# to support Python bytes operations like startswith()
119+
if self._storage_client._is_rust_client_enabled() and hasattr(data, "to_bytes"):
120+
data = data.to_bytes()
117121
# Update the position by the number of bytes read
118122
bytes_read = len(data)
119123
self._pos += bytes_read

0 commit comments

Comments
 (0)