Module magnus::encoding

source ·
Expand description

Types and functions for working with encodings.

This module defines 3 types for working with encodings, these types can be converted back and forth with From/Into like so:

Encoding <-> RbEncoding <-> Index
      |______________________^

Many functions that require an encoding take thier arguments as Into<RbEncoding> or Into<Index> to ease working with the different types. The type specified for the Into conversion hints at the type the function nativly works with, and thus will avoid any conversion cost.

Encoding and RbEncoding both implement TryConvert and IntoValue so can be used as parameters and return values in functions bound to Ruby. Both convert from either an instance of Encoding or a string of an encoding name, and convert to an instance of Encoding.

Structs§

  • Wrapper type for a Value known to be an instance of Ruby’s Encoding class.
  • The index of an encoding in Ruby’s internal encodings table.
  • Ruby’s internal encoding type.

Enums§

Traits§

Functions§

  • Returns the common encoding between v1 and v2, or Err.
  • Returns the common encoding between v1 and v2, or None.
  • Compies the encoding from src to dst.