#[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§
source§impl Index
impl Index
sourcepub fn locale() -> Self
pub fn locale() -> Self
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.
sourcepub fn filesystem() -> Self
pub fn filesystem() -> Self
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.
sourcepub fn find(name: &str) -> Result<Self, Error>
pub fn find(name: &str) -> Result<Self, Error>
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§
source§impl From<Index> for RbEncoding
impl From<Index> for RbEncoding
source§impl From<RbEncoding> for Index
impl From<RbEncoding> for Index
source§fn from(val: RbEncoding) -> Self
fn from(val: RbEncoding) -> Self
Converts to this type from the input type.