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§
Sourcefn encode(
&self,
buf: Borrowed<'_, 'py, PyAny>,
) -> Result<Bound<'py, PyAny>, PyErr>
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.
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
PyCodecClassMethods::codec_id.
The dict must be compatible with JSON encoding.
§Errors
Errors if getting the codec configuration fails.
Sourcefn class(&self) -> Bound<'py, PyCodecClass>
fn class(&self) -> Bound<'py, PyCodecClass>
Returns the PyCodecClass of this codec.