/// Wraps Rust structure into a new Ruby object of the current module.
///
/// See the documentation for `wrappable_struct!` macro for more information.
///
/// # Examples
///
/// Wrap `Server` structs to `RubyServer` objects.  Note: Example shows use
/// with class but the method still applies to module.
///
/// ```
/// #[macro_use] extern crate rutie;
/// #[macro_use] extern crate lazy_static;
///
/// use rutie::{AnyObject, Class, Fixnum, Object, RString, VM};
///
/// // The structure which we want to wrap
/// pub struct Server {
///     host: String,
///     port: u16,
/// }
///
/// impl Server {
///     fn new(host: String, port: u16) -> Self {
///         Server {
///             host: host,
///             port: port,
///         }
///     }
///
///     fn host(&self) -> &str {
///         &self.host
///     }
///
///     fn port(&self) -> u16 {
///         self.port
///     }
/// }
///
/// wrappable_struct!(Server, ServerWrapper, SERVER_WRAPPER);
///
/// class!(RubyServer);
///
/// methods!(
///     RubyServer,
///     rtself,
///
///     fn ruby_server_new(host: RString, port: Fixnum) -> AnyObject {
///         let server = Server::new(host.unwrap().to_string(),
///                                  port.unwrap().to_i64() as u16);
///
///         Class::from_existing("RubyServer").wrap_data(server, &*SERVER_WRAPPER)
///     }
///
///     fn ruby_server_host() -> RString {
///         let host = rtself.get_data(&*SERVER_WRAPPER).host();
///
///         RString::new_utf8(host)
///     }
///
///     fn ruby_server_port() -> Fixnum {
///         let port = rtself.get_data(&*SERVER_WRAPPER).port();
///
///         Fixnum::new(port as i64)
///     }
/// );
///
/// fn main() {
///     # VM::init();
///     let data_class = Class::from_existing("Object");
///
///     Class::new("RubyServer", None).define(|klass| {
///         klass.def_self("new", ruby_server_new);
///
///         klass.def("host", ruby_server_host);
///         klass.def("port", ruby_server_port);
///     });
/// }
/// ```
///
/// To use the `RubyServer` class in Ruby:
///
/// ```ruby
/// server = RubyServer.new("127.0.0.1", 3000)
///
/// server.host == "127.0.0.1"
/// server.port == 3000
/// ```
Wraps Rust structure into a new Ruby object of the current module.
See the documentation for `wrappable_struct!` macro for more information.
Wraps Rust structure into a new Ruby object of the current module . See the documentation for ` wrappable_struct! ` macro for more information .
pub fn wrap_data<T, O: Object>(&self, data: T, wrapper: &dyn DataTypeWrapper<T>) -> O {
        let value = class::wrap_data(self.value(), data, wrapper);
        O::from(value)
    }
pub fn wrap_data < T , O : Object > ( & self , data : T , wrapper : & dyn DataTypeWrapper < T > ) -> O { let value = class :: wrap_data ( self . value ( ) , data , wrapper ) ; O :: from ( value ) }
Wraps Rust structure into a new Ruby object of the current module.
Wraps Rust structure into a new Ruby object of the current module .
&self
data
T
wrapper
&dyn DataTypeWrapper<T>
examples
Wrap `Server` structs to `RubyServer` objects.  Note: Example shows use
with class but the method still applies to module.


Wrap ` Server ` structs to ` RubyServer ` objects . Note : Example shows use with class but the method still applies to module .
[macro_use] extern crate rutie;
None
[macro_use] extern crate lazy_static;
use rutie::{AnyObject, Class, Fixnum, Object, RString, VM}.

The structure which we want to wrap
pub struct Server {
host: String,
port: u16,
}

impl Server {
fn new(host: String, port: u16) -> Self {
Server {
host: host,
port: port,
}
}

fn host(&self) -> &str {
&self.host
}



wrappable_struct!(Server, ServerWrapper, SERVER_WRAPPER).

class!(RubyServer).

methods!(
RubyServer,
rtself.

fn ruby_server_new(host: RString, port: Fixnum) -> AnyObject {
let server = Server::new(host.unwrap().to_string(),
port.unwrap().to_i64() as u16).

:from_existing("RubyServer").wrap_data(server, &*SERVER_WRAPPER)
}

fn ruby_server_host() -> RString {
let host = rtself.get_data(&*SERVER_WRAPPER).host().



fn ruby_server_port() -> Fixnum {
let port = rtself.get_data(&*SERVER_WRAPPER).port().



fn main() {
VM::init();
let data_class = Class::from_existing("Object").

:new("RubyServer", None).define(|klass| {
klass.def_self("new", ruby_server_new).

klass.def("host", ruby_server_host);
klass.def("port", ruby_server_port);
});
}
```

To use the `RubyServer` class in Ruby.




use rutie :: { AnyObject Class Fixnum Object RString VM } . The structure which we want to wrap pub struct Server { host : String port : u16 } impl Server { fn new ( host : String port : u16 ) - > Self { Server { host : host port : port } } fn host ( &self ) - > &str { &self . host } wrappable_struct! ( Server ServerWrapper SERVER_WRAPPER ) . class! ( RubyServer ) . methods! ( RubyServer rtself . fn ruby_server_new ( host : RString port : Fixnum ) - > AnyObject { let server = Server :: new ( host . unwrap () . to_string () port . unwrap () . to_i64 () as u16 ) . : from_existing ( " RubyServer " ) . wrap_data ( server & * SERVER_WRAPPER ) } fn ruby_server_host () - > RString { let host = rtself . get_data ( & * SERVER_WRAPPER ) . host () . fn ruby_server_port () - > Fixnum { let port = rtself . get_data ( & * SERVER_WRAPPER ) . port () . fn main () { VM :: init () ; let data_class = Class :: from_existing ( " Object " ) . : new ( " RubyServer " None ) . define ( |klass| { klass . def_self ( " new " ruby_server_new ) . klass . def ( " host " ruby_server_host ) ; klass . def ( " port " ruby_server_port ) ; } ) ; } ` ` ` To use the ` RubyServer ` class in Ruby .