artichoke_backend/extn/core/encoding/
mruby.rs1use std::ffi::CStr;
2
3use crate::extn::core::encoding;
4use crate::extn::prelude::*;
5
6const ENCODING_CSTR: &CStr = c"Encoding";
7static ENCODING_RUBY_SOURCE: &[u8] = include_bytes!("encoding.rb");
8
9pub fn init(interp: &mut Artichoke) -> InitializeResult<()> {
10 if interp.is_class_defined::<encoding::Encoding>() {
11 return Ok(());
12 }
13
14 let spec = class::Spec::new("Encoding", ENCODING_CSTR, None, None)?;
15 class::Builder::for_spec(interp, &spec).define()?;
16 interp.def_class::<encoding::Encoding>(spec)?;
17 interp.eval(ENCODING_RUBY_SOURCE)?;
18
19 Ok(())
20}