Document how to handle CBOR objects concatenated in a stream
- Lenguaje dominante
- Rust
- Estrellas
- 305
- Forks
- 79
- Merge medio
- 21 h 59 min
- PR fusionados (30 d)
- 2
Descripción
An EOF while decoding should not be used to signal the end of a stream.
If you're decoding a set of CBOR objects that are just concatenated together in a file without delimiters then do this:
```python
from cbor2 import CBORDecoder
with open('myfile.cbor', 'rb') as f:
decoder = CBORDecoder(f)
while f.peek(1): # Check that there's data at the next file position
print(decoder.decode())
print('Done!')
```
Otherwise wrap the items in an indefinite length array.
This is equivalent to how you would decode cbor from a network socket or queue, you always expect a complete item and if you don't it's corrupted data. Hence EOF errors do not make sense to pass up to the reader.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.