Skip to content

Commit 490df9b

Browse files
committed
adds missing readif method
1 parent 6011c29 commit 490df9b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

refinery/lib/structures.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ def read(self, size: int = -1, peek: bool = False) -> T:
194194
self._cursor = end
195195
return result
196196

197+
def readif(self, value: bytes) -> bool:
198+
size = len(value)
199+
stop = self._cursor + size
200+
mv = memoryview(self._data)
201+
if match := mv[self._cursor:stop] == value:
202+
self._cursor = stop
203+
return match
204+
197205
def peek(self, size: int = -1) -> memoryview:
198206
cursor = self._cursor
199207
mv = memoryview(self._data)

0 commit comments

Comments
 (0)