Skip to main content

py_bytes_to_bytes

Function py_bytes_to_bytes 

Source
pub fn py_bytes_to_bytes(py_bytes: Py<PyBytes>) -> Bytes
Expand description

Wrap an immutable Python bytes as a zero-copy [Bytes] that pins the PyBytes alive for the returned buffer’s lifetime, so its payload is never copied. This is the shared conversion behind Buffer::take_part’s reference fragments; callers that slice a block into chunks (e.g. the chain-broadcast source) reuse it to egress the block without a copy.