Trait numcodecs_python::PyCodecMethods

source ·
pub trait PyCodecMethods<'py>: Sealed {
    // Required methods
    fn encode(
        &self,
        buf: Borrowed<'_, 'py, PyAny>,
    ) -> Result<Bound<'py, PyAny>, PyErr>;
    fn decode(
        &self,
        buf: Borrowed<'_, 'py, PyAny>,
        out: Option<Borrowed<'_, 'py, PyAny>>,
    ) -> Result<Bound<'py, PyAny>, PyErr>;
    fn get_config(&self) -> Result<Bound<'py, PyDict>, PyErr>;
    fn class(&self) -> Bound<'py, PyCodecClass>;
}
Expand description

Methods implemented for PyCodecs.

Required Methods§

source

fn encode( &self, buf: Borrowed<'_, 'py, PyAny>, ) -> Result<Bound<'py, PyAny>, PyErr>

Encodes the data in the buffer buf and returns the result.

The input and output buffers be any objects supporting the new-style buffer protocol.

§Errors

Errors if encoding the buffer fails.

source

fn decode( &self, buf: Borrowed<'_, 'py, PyAny>, out: Option<Borrowed<'_, 'py, PyAny>>, ) -> Result<Bound<'py, PyAny>, PyErr>

Decodes the data in the buffer buf and returns the result.

The input and output buffers be any objects supporting the new-style buffer protocol.

If the optional output buffer out is provided, the decoded data is written into out and the out buffer is returned. Note that this buffer must be exactly the right size to store the decoded data.

If the optional output buffer out is not provided, a new output buffer is allocated.

§Errors

Errors if decoding the buffer fails.

source

fn get_config(&self) -> Result<Bound<'py, PyDict>, PyErr>

Returns a dictionary holding configuration parameters for this codec.

The dict must include an id field with the PyCodecClassMethods::codec_id.

The dict must be compatible with JSON encoding.

§Errors

Errors if getting the codec configuration fails.

source

fn class(&self) -> Bound<'py, PyCodecClass>

Returns the PyCodecClass of this codec.

Implementations on Foreign Types§

source§

impl<'py> PyCodecMethods<'py> for Bound<'py, PyCodec>

source§

fn encode( &self, buf: Borrowed<'_, 'py, PyAny>, ) -> Result<Bound<'py, PyAny>, PyErr>

source§

fn decode( &self, buf: Borrowed<'_, 'py, PyAny>, out: Option<Borrowed<'_, 'py, PyAny>>, ) -> Result<Bound<'py, PyAny>, PyErr>

source§

fn get_config(&self) -> Result<Bound<'py, PyDict>, PyErr>

source§

fn class(&self) -> Bound<'py, PyCodecClass>

Implementors§