Crate encoding_c

source
Expand description

The C API for encoding_rs.

§Mapping from Rust

§Naming convention

The wrapper function for each method has a name that starts with the name of the struct lower-cased, followed by an underscore and ends with the name of the method.

For example, Encoding::for_label() is wrapped as encoding_for_label().

§Arguments

Functions that wrap non-static methods take the self object as their first argument.

Slice argument foo is decomposed into a pointer foo and a length foo_len.

§Return values

Multiple return values become out-params. When an out-param is length-related, foo_len for a slice becomes a pointer in order to become an in/out-param.

DecoderResult, EncoderResult and CoderResult become uint32_t. InputEmpty becomes INPUT_EMPTY. OutputFull becomes OUTPUT_FULL. Unmappable becomes the scalar value of the unmappable character. Malformed becomes a number whose lowest 8 bits, which can have the decimal value 0, 1, 2 or 3, indicate the number of bytes that were consumed after the malformed sequence and whose next-lowest 8 bits, when shifted right by 8 indicate the length of the malformed byte sequence (possible decimal values 1, 2, 3 or 4). The maximum possible sum of the two is 6.

Structs§

  • Newtype for *const Encoding in order to be able to implement Sync for it.

Constants§

  • The minimum length of buffers that may be passed to encoding_name().
  • Return value for *_decode_* and *_encode_* functions that indicates that the input has been exhausted.
  • Return value for *_decode_* and *_encode_* functions that indicates that the output space has been exhausted.

Statics§

Functions§