Struct magnus::RFile

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

A Value pointer to a RFile struct, Ruby’s internal representation of files.

All Value methods should be available on this type through Deref, but some may be missed by this documentation.

Implementations§

source§

impl RFile

source

pub fn from_value(val: Value) -> Option<Self>

Return Some(RFile) if val is a RFile, None otherwise.

Methods from Deref<Target = Value>§

source

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");
source

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 Clone for RFile

source§

fn clone(&self) -> RFile

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RFile

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for RFile

§

type Target = Value

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Display for RFile

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<RFile> for Value

source§

fn from(val: RFile) -> Self

Converts to this type from the input type.
source§

impl IntoValue for RFile

source§

fn into_value_with(self, _: &RubyHandle) -> Value

Convert self into Value.
source§

fn into_value(self) -> Value

Convert self into Value. Read more
source§

unsafe fn into_value_unchecked(self) -> Value

Convert self into Value. Read more
source§

impl Object for RFile

source§

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
source§

fn ivar_get<T, U>(self, name: T) -> Result<U, Error>where T: IntoId, U: TryConvert,

Get the value for the instance variable name within self’s scope. Read more
source§

fn ivar_set<T, U>(self, name: T, value: U) -> Result<(), Error>where T: IntoId, U: IntoValue,

Set the value for the instance variable name within self’s scope. Read more
source§

fn singleton_class(self) -> Result<RClass, Error>

Finds or creates the singleton class of self. Read more
source§

fn extend_object(self, module: RModule) -> Result<(), Error>

Extend self with module. Read more
source§

impl TryConvert for RFile

source§

fn try_convert(val: Value) -> Result<Self, Error>

Convert val into Self.
source§

impl Copy for RFile

source§

impl ReprValue for RFile

Auto Trait Implementations§

§

impl RefUnwindSafe for RFile

§

impl Send for RFile

§

impl Sync for RFile

§

impl Unpin for RFile

§

impl UnwindSafe for RFile

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> BlockReturn for Twhere T: BlockReturn,

source§

impl<T> ReturnValue for Twhere T: ReturnValue,