Bytes.from_bytes


Description:

public Bytes.from_bytes (Bytes bytes, size_t offset, size_t length)

Creates a Bytes which is a subsection of another Bytes.

The offset + length may not be longer than the size of this.

A reference to this will be held by the newly created Bytes until the byte data is no longer needed.

Since 2.56, if offset is 0 and length matches the size of this, then this will be returned with the reference count incremented by 1. If this is a slice of another Bytes, then the resulting Bytes will reference the same Bytes instead of this. This allows consumers to simplify the usage of Bytes when asynchronously writing to streams.

Parameters:

this

a Bytes

offset

offset which subsection starts at

length

length of subsection

Returns:

a new Bytes