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
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.
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.
Trait Implementations
fn default() -> RustyBufferⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
fn default() -> RustyBufferⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
Returns the “default value” for a type. Read more
fn bf_getbuffer(
slf: PyRefMut<'_, Self>,
view: *mut Py_buffer,
flags: c_int
) -> <RustyBuffer as PyBufferGetBufferProtocol<'p>>::ResultⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
fn bf_releasebuffer(
_slf: PyRefMut<'_, Self>,
_view: *mut Py_buffer
) -> <RustyBuffer as PyBufferReleaseBufferProtocol<'p>>::ResultⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
type Dict = PyClassDummySlot
type Dict = PyClassDummySlot
Specify this class has #[pyclass(dict)]
or not.
type WeakRef = PyClassDummySlot
type WeakRef = PyClassDummySlot
Specify this class has #[pyclass(weakref)]
or not.
type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
. Read more
#[pyclass(subclass)]
#[pyclass(extends=…)]
type ThreadChecker = ThreadCheckerStub<RustyBuffer>
type ThreadChecker = ThreadCheckerStub<RustyBuffer>
This handles following two situations: Read more
fn __repr__(&'p self) -> <RustyBuffer as PyObjectReprProtocol<'p>>::ResultⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
fn __bool__(&'p self) -> <RustyBuffer as PyObjectBoolProtocol<'p>>::ResultⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
fn __getattr__(&'p self, name: Self::Name) -> Self::Result where
Self: PyObjectGetAttrProtocol<'p>,
fn __setattr__(
&'p mut self,
name: Self::Name,
value: Self::Value
) -> Self::Result where
Self: PyObjectSetAttrProtocol<'p>,
fn __delattr__(&'p mut self, name: Self::Name) -> Self::Result where
Self: PyObjectDelAttrProtocol<'p>,
fn __format__(&'p self, format_spec: Self::Format) -> Self::Result where
Self: PyObjectFormatProtocol<'p>,
fn __format__(&'p self, format_spec: Self::Format) -> Self::Result where
Self: PyObjectFormatProtocol<'p>,
prefer implementing __format__
in #[pymethods]
instead of in a protocol
prefer implementing __bytes__
in #[pymethods]
instead of in a protocol
fn __richcmp__(&'p self, other: Self::Other, op: CompareOp) -> Self::Result where
Self: PyObjectRichcmpProtocol<'p>,
fn __len__(&'p self) -> <RustyBuffer as PySequenceLenProtocol<'p>>::ResultⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
fn __contains__(
&'p self,
x: <RustyBuffer as PySequenceContainsProtocol<'p>>::Item
) -> <RustyBuffer as PySequenceContainsProtocol<'p>>::ResultⓘNotable traits for RustyBufferimpl Read for RustyBufferimpl Write for RustyBuffer
impl Read for RustyBufferimpl Write for RustyBuffer
fn __getitem__(&'p self, idx: Self::Index) -> Self::Result where
Self: PySequenceGetItemProtocol<'p>,
fn __setitem__(
&'p mut self,
idx: Self::Index,
value: Self::Value
) -> Self::Result where
Self: PySequenceSetItemProtocol<'p>,
fn __delitem__(&'p mut self, idx: Self::Index) -> Self::Result where
Self: PySequenceDelItemProtocol<'p>,
fn __concat__(&'p self, other: Self::Other) -> Self::Result where
Self: PySequenceConcatProtocol<'p>,
fn __repeat__(&'p self, count: Self::Index) -> Self::Result where
Self: PySequenceRepeatProtocol<'p>,
fn __inplace_concat__(&'p mut self, other: Self::Other) -> Self::Result where
Self: PySequenceInplaceConcatProtocol<'p>,
fn __inplace_repeat__(&'p mut self, count: Self::Index) -> Self::Result where
Self: PySequenceInplaceRepeatProtocol<'p>,
type AsRefTarget = PyCell<Self>
type AsRefTarget = PyCell<Self>
Utility type to make Py::as_ref work.
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
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
read_initializer
)Determines if this Read
er 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
Creates an adapter which will chain this stream with another. 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
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
Attempts to write an entire buffer into this writer. Read more
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