numcodecs_python

Trait 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§