Struct cramjam::io::RustyBuffer[][src]

pub struct RustyBuffer { /* fields omitted */ }
Expand description

A native Rust file-like object. Reading and writing takes place through the Rust implementation, allowing access to the underlying bytes in Python.

Python Example

>>> from cramjam import Buffer
>>> buf = Buffer(b"bytes")
>>> buf.read()
b'bytes'

Implementations

A Buffer object, similar to cramjam.File only the bytes are held in-memory

Example

from cramjam import Buffer
buf = Buffer(b'start bytes')
buf.read(5)
b'start'

Instantiate the object, optionally with any supported bytes-like object in BytesType

Length of the underlying buffer

Write some bytes to the buffer, where input data can be anything in BytesType

Read from the buffer in its current position, returns bytes; optionally specify number of bytes to read.

Read from the buffer in its current position, into a BytesType object.

Seek to a position within the buffer. whence follows the same values as IOBase.seek where:

0: from start of the stream
1: from current stream position
2: from end of the stream

Whether the buffer is seekable; here just for compatibility, it always returns True.

Give the current position of the buffer.

Set the length of the buffer. If less than current length, it will truncate to the size given; otherwise will be null byte filled to the size.

Truncate the buffer

Trait Implementations

Returns the “default value” for a type. Read more

Performs the conversion.

Performs the conversion.

Specify this class has #[pyclass(dict)] or not.

Specify this class has #[pyclass(weakref)] or not.

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict. Read more

Class doc string

#[pyclass(gc)]

#[pyclass(subclass)]

#[pyclass(extends=…)]

Layout

Base class

This handles following two situations: Read more

👎 Deprecated since 0.14.0:

prefer implementing __format__ in #[pymethods] instead of in a protocol

👎 Deprecated since 0.14.0:

prefer implementing __bytes__ in #[pymethods] instead of in a protocol

Utility type to make Py::as_ref work.

Class name.

Module name, if any.

PyTypeObject instance for this type.

Checks if object is an instance of this type or a subclass of this type.

Checks if object is an instance of this type.

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Like read, except that it reads into a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adapter for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Seek to an offset, in bytes, in a stream. Read more

Rewind to the beginning of a stream. Read more

🔬 This is a nightly-only experimental API. (seek_stream_len)

Returns the length of this stream (in bytes). Read more

Returns the current seek position from the start of the stream. Read more

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Arguments for exception

Returns the safe abstraction over the type object.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.