Struct magnus::exception::ExceptionClass
source · #[repr(transparent)]pub struct ExceptionClass(_);
Expand description
Implementations§
source§impl ExceptionClass
impl ExceptionClass
sourcepub fn from_value(val: Value) -> Option<Self>
pub fn from_value(val: Value) -> Option<Self>
Return Some(ExceptionClass)
if val
is an ExceptionClass
, None
otherwise.
Methods from Deref<Target = Value>§
sourcepub unsafe fn to_s(&self) -> Result<Cow<'_, str>, Error>
pub unsafe fn to_s(&self) -> Result<Cow<'_, str>, Error>
Convert self
to a Rust string.
Safety
This may return a direct view of memory owned and managed by Ruby. Ruby may modify or free the memory backing the returned str, the caller must ensure this does not happen.
This can be used safely by immediately calling
into_owned
on the return value.
Examples
use magnus::{eval, QTRUE};
let value = QTRUE;
// safe as we neve give Ruby a chance to free the string.
let s = unsafe { value.to_s() }.unwrap().into_owned();
assert_eq!(s, "true");
sourcepub unsafe fn classname(&self) -> Cow<'_, str>
pub unsafe fn classname(&self) -> Cow<'_, str>
Return the name of self
’s class.
Safety
Ruby may modify or free the memory backing the returned str, the caller must ensure this does not happen.
This can be used safely by immediately calling
into_owned
on the return value.
Examples
use magnus::{eval, RHash};
let value = RHash::new();
// safe as we never give Ruby a chance to free the string.
let s = unsafe { value.classname() }.into_owned();
assert_eq!(s, "Hash");
Trait Implementations§
source§impl Class for ExceptionClass
impl Class for ExceptionClass
source§impl Clone for ExceptionClass
impl Clone for ExceptionClass
source§fn clone(&self) -> ExceptionClass
fn clone(&self) -> ExceptionClass
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ExceptionClass
impl Debug for ExceptionClass
source§impl Default for ExceptionClass
impl Default for ExceptionClass
source§impl Deref for ExceptionClass
impl Deref for ExceptionClass
source§impl Display for ExceptionClass
impl Display for ExceptionClass
source§impl From<ExceptionClass> for Value
impl From<ExceptionClass> for Value
source§fn from(val: ExceptionClass) -> Self
fn from(val: ExceptionClass) -> Self
Converts to this type from the input type.
source§impl Module for ExceptionClass
impl Module for ExceptionClass
source§fn define_class<T: Into<Id>>(
self,
name: T,
superclass: RClass
) -> Result<RClass, Error>
fn define_class<T: Into<Id>>(
self,
name: T,
superclass: RClass
) -> Result<RClass, Error>
Define a class in
self
’s scope. Read moresource§fn define_module<T: Into<Id>>(self, name: T) -> Result<RModule, Error>
fn define_module<T: Into<Id>>(self, name: T) -> Result<RModule, Error>
Define a module in
self
’s scope. Read moresource§fn define_error<T: Into<Id>>(
self,
name: T,
superclass: ExceptionClass
) -> Result<ExceptionClass, Error>
fn define_error<T: Into<Id>>(
self,
name: T,
superclass: ExceptionClass
) -> Result<ExceptionClass, Error>
Define an exception class in
self
’s scope. Read moresource§fn const_set<T, U>(self, name: T, value: U) -> Result<(), Error>where
T: Into<Id>,
U: Into<Value>,
fn const_set<T, U>(self, name: T, value: U) -> Result<(), Error>where
T: Into<Id>,
U: Into<Value>,
source§fn ancestors(self) -> RArray
fn ancestors(self) -> RArray
Return the classes and modules
self
inherits, includes, or prepends. Read moresource§fn define_method<T, M>(self, name: T, func: M) -> Result<(), Error>where
T: Into<Id>,
M: Method,
fn define_method<T, M>(self, name: T, func: M) -> Result<(), Error>where
T: Into<Id>,
M: Method,
Define a method in
self
’s scope. Read moresource§fn define_private_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_private_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a private method in
self
’s scope. Read moresource§fn define_protected_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_protected_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a protected method in
self
’s scope. Read moresource§impl Object for ExceptionClass
impl Object for ExceptionClass
source§fn define_singleton_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_singleton_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a singleton method in
self
’s scope. Read more