pub struct Encoding(/* private fields */);
Expand description
Implementations§
source§impl Encoding
impl Encoding
sourcepub fn from_value(val: Value) -> Option<Self>
pub fn from_value(val: Value) -> Option<Self>
Return Some(Encoding)
if val
is an Encoding
, None
otherwise.
§Examples
use magnus::{encoding::Encoding, eval};
assert!(Encoding::from_value(eval("Encoding::US_ASCII").unwrap()).is_some());
assert!(Encoding::from_value(eval("nil").unwrap()).is_none());
sourcepub fn default_external() -> Self
pub fn default_external() -> Self
Returns the default internal encoding as a Ruby object.
This is the encoding used for anything out-of-process, such as reading from files or sockets.
§Panics
Panics if called from a non-Ruby thread. See
Ruby::enc_default_external
for the non-panicking version.
sourcepub fn default_internal() -> Option<Self>
pub fn default_internal() -> Option<Self>
Returns the default external encoding as a Ruby object.
If set, any out-of-process data is transcoded from the default external encoding to the default internal encoding.
§Panics
Panics if called from a non-Ruby thread. See
Ruby::enc_default_internal
for the non-panicking version.
Trait Implementations§
source§impl From<Encoding> for RbEncoding
impl From<Encoding> for RbEncoding
source§impl From<RbEncoding> for Encoding
impl From<RbEncoding> for Encoding
source§fn from(val: RbEncoding) -> Self
fn from(val: RbEncoding) -> Self
Converts to this type from the input type.
source§impl Object for Encoding
impl Object for Encoding
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 moresource§impl ReprValue for Encoding
impl ReprValue for Encoding
source§fn equal<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
fn equal<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
Checks for equality, delegating to the Ruby method
#==
. Read moresource§fn eql<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
fn eql<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
Checks for equality, delegating to the Ruby method
#eql?
. Read moresource§fn hash(self) -> Result<Integer, Error>
fn hash(self) -> Result<Integer, Error>
Returns an integer non-uniquely identifying
self
. Read moresource§fn to_bool(self) -> bool
fn to_bool(self) -> bool
Convert
self
to a bool
, following Ruby’s rules of false
and nil
as boolean false
and everything else boolean true
. Read moresource§fn funcall_public<M, A, T>(self, method: M, args: A) -> Result<T, Error>
fn funcall_public<M, A, T>(self, method: M, args: A) -> Result<T, Error>
source§fn block_call<M, A, R, T>(
self,
method: M,
args: A,
block: fn(_: &[Value], _: Option<Proc>) -> R
) -> Result<T, Error>
fn block_call<M, A, R, T>( self, method: M, args: A, block: fn(_: &[Value], _: Option<Proc>) -> R ) -> Result<T, Error>
source§fn respond_to<M>(self, method: M, include_private: bool) -> Result<bool, Error>where
M: IntoId,
fn respond_to<M>(self, method: M, include_private: bool) -> Result<bool, Error>where
M: IntoId,
Check if
self
responds to the given Ruby method. Read moresource§fn is_kind_of<T>(self, class: T) -> bool
fn is_kind_of<T>(self, class: T) -> bool
source§fn enumeratorize<M, A>(self, method: M, args: A) -> Enumerator ⓘwhere
M: IntoSymbol,
A: ArgList,
fn enumeratorize<M, A>(self, method: M, args: A) -> Enumerator ⓘwhere
M: IntoSymbol,
A: ArgList,
source§impl TryConvert for Encoding
impl TryConvert for Encoding
impl Copy for Encoding
Auto Trait Implementations§
impl Freeze for Encoding
impl RefUnwindSafe for Encoding
impl Send for Encoding
impl Sync for Encoding
impl Unpin for Encoding
impl UnwindSafe for Encoding
Blanket Implementations§
source§impl<T> AsRawValue for Twhere
T: ReprValue,
impl<T> AsRawValue for Twhere
T: ReprValue,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more