Struct magnus::encoding::Index

source ·
#[repr(transparent)]
pub struct Index(_);
Expand description

The index of an encoding in Ruby’s internal encodings table.

This is the type Ruby uses to label encoding capable types, so is used with operations that require reading or setting that label.

Implementations§

Returns the index for ASCII-8BIT a.k.a. binary.

Returns the index for UTF-8.

Returns the index for US-ASCII.

Returns the index for the process’ current locale encoding.

This is dynamic. If you change the process’ locale that should also change the return value of this function.

Returns the index for filesystem encoding.

This is the encoding that Ruby expects data from the OS’ file system to be encoded as, such as directory names.

Returns the index for the encoding with the name or alias name.

Examples
use magnus::{eval, encoding};

assert!(encoding::Index::find("UTF-8").is_ok());
assert!(encoding::Index::find("BINARY").is_ok());
assert!(encoding::Index::find("none").is_err());

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Convert val into Self.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.