Trait numcodecs_python::CodecMethods
source · pub trait CodecMethods<'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, CodecClass>;
}
Expand description
Methods implemented for Codec
s.
Required Methods§
sourcefn encode(
&self,
buf: Borrowed<'_, 'py, PyAny>,
) -> Result<Bound<'py, PyAny>, PyErr>
fn encode( &self, buf: Borrowed<'_, 'py, PyAny>, ) -> Result<Bound<'py, PyAny>, PyErr>
Encode 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.
sourcefn decode(
&self,
buf: Borrowed<'_, 'py, PyAny>,
out: Option<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>
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.
sourcefn get_config(&self) -> Result<Bound<'py, PyDict>, PyErr>
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
CodecClassMethods::codec_id
. The dict must be compatible with JSON
encoding.
§Errors
Errors if getting the codec configuration fails.
sourcefn class(&self) -> Bound<'py, CodecClass>
fn class(&self) -> Bound<'py, CodecClass>
Returns the CodecClass
of this codec.