pub struct Context {Show 16 fields
pub true_value: PyRef<PyBool>,
pub false_value: PyRef<PyBool>,
pub none: PyRef<PyNone>,
pub empty_tuple: PyTupleRef,
pub empty_frozenset: PyRef<PyFrozenSet>,
pub empty_str: &'static PyStrInterned,
pub empty_bytes: PyRef<PyBytes>,
pub ellipsis: PyRef<PyEllipsis>,
pub not_implemented: PyRef<PyNotImplemented>,
pub typing_no_default: PyRef<NoDefault>,
pub types: TypeZoo,
pub exceptions: ExceptionZoo,
pub int_cache_pool: Vec<PyIntRef>,
pub names: ConstName,
pub gc_callbacks: PyListRef,
pub gc_garbage: PyListRef,
/* private fields */
}Fields§
§true_value: PyRef<PyBool>§false_value: PyRef<PyBool>§none: PyRef<PyNone>§empty_tuple: PyTupleRef§empty_frozenset: PyRef<PyFrozenSet>§empty_str: &'static PyStrInterned§empty_bytes: PyRef<PyBytes>§ellipsis: PyRef<PyEllipsis>§not_implemented: PyRef<PyNotImplemented>§typing_no_default: PyRef<NoDefault>§types: TypeZoo§exceptions: ExceptionZoo§int_cache_pool: Vec<PyIntRef>§names: ConstName§gc_callbacks: PyListRef§gc_garbage: PyListRefImplementations§
Source§impl Context
impl Context
pub const INT_CACHE_POOL_RANGE: RangeInclusive<i32>
pub fn genesis() -> &'static PyRc<Self>
pub fn intern_str<S: InternableString>(&self, s: S) -> &'static PyStrInterned
pub fn interned_str<S: MaybeInternedString + ?Sized>( &self, s: &S, ) -> Option<&'static PyStrInterned>
pub fn none(&self) -> PyObjectRef
pub fn not_implemented(&self) -> PyObjectRef
pub fn empty_tuple_typed<T>(&self) -> &Py<PyTuple<T>>
pub fn new_pyref<T, P>(&self, value: T) -> PyRef<P>
pub fn new_int<T: Into<BigInt> + ToPrimitive>(&self, i: T) -> PyIntRef
pub fn new_bigint(&self, i: &BigInt) -> PyIntRef
pub fn new_float(&self, value: f64) -> PyRef<PyFloat>
pub fn new_complex(&self, value: Complex64) -> PyRef<PyComplex>
pub fn latin1_char(&self, ch: u8) -> PyRef<PyStr>
pub fn new_str(&self, s: impl Into<PyStr>) -> PyRef<PyStr>
pub fn new_utf8_str(&self, s: impl Into<PyUtf8Str>) -> PyRef<PyUtf8Str>
pub fn interned_or_new_str<S, M>(&self, s: S) -> PyRef<PyStr>
pub fn new_bytes(&self, data: Vec<u8>) -> PyRef<PyBytes>
pub fn new_bytearray(&self, data: Vec<u8>) -> PyRef<PyByteArray>
pub fn new_bool(&self, b: bool) -> PyRef<PyBool>
pub fn new_tuple(&self, elements: Vec<PyObjectRef>) -> PyTupleRef
pub fn new_list(&self, elements: Vec<PyObjectRef>) -> PyListRef
pub fn new_dict(&self) -> PyDictRef
pub fn new_class( &self, module: Option<&str>, name: &str, base: PyTypeRef, slots: PyTypeSlots, ) -> PyTypeRef
pub fn new_exception_type( &self, module: &str, name: &str, bases: Option<Vec<PyTypeRef>>, ) -> PyTypeRef
pub fn new_method_def<F, FKind>(
&self,
name: &'static str,
f: F,
flags: PyMethodFlags,
doc: Option<&'static str>,
) -> PyRef<HeapMethodDef>where
F: IntoPyNativeFn<FKind>,
pub fn new_member( &self, name: &str, member_kind: MemberKind, getter: fn(&VirtualMachine, PyObjectRef) -> PyResult, setter: Option<fn(&VirtualMachine, PyObjectRef, PySetterValue) -> PyResult<()>>, class: &'static Py<PyType>, ) -> PyRef<PyMemberDescriptor>
pub fn new_readonly_getset<F, T>(
&self,
name: impl Into<String>,
class: &'static Py<PyType>,
f: F,
) -> PyRef<PyGetSet>where
F: IntoPyGetterFunc<T>,
pub fn new_static_getset<G, S, T, U>(
&self,
name: impl Into<String>,
class: &'static Py<PyType>,
g: G,
s: S,
) -> PyRef<PyGetSet>where
G: IntoPyGetterFunc<T>,
S: IntoPySetterFunc<U>,
Sourcepub unsafe fn new_getset<G, S, T, U>(
&self,
name: impl Into<String>,
class: &Py<PyType>,
g: G,
s: S,
) -> PyRef<PyGetSet>where
G: IntoPyGetterFunc<T>,
S: IntoPySetterFunc<U>,
pub unsafe fn new_getset<G, S, T, U>(
&self,
name: impl Into<String>,
class: &Py<PyType>,
g: G,
s: S,
) -> PyRef<PyGetSet>where
G: IntoPyGetterFunc<T>,
S: IntoPySetterFunc<U>,
Creates a new PyGetSet with a heap type.
§Safety
In practice, this constructor is safe because a getset is always owned by its class type.
However, it can be broken if used unconventionally.
pub fn new_base_object( &self, class: PyTypeRef, dict: Option<PyDictRef>, ) -> PyObjectRef
pub fn new_code(&self, code: impl IntoCodeObject) -> PyRef<PyCode>
Trait Implementations§
Source§impl AsRef<Context> for VirtualMachine
impl AsRef<Context> for VirtualMachine
Auto Trait Implementations§
impl !Freeze for Context
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl !UnwindSafe for Context
Blanket Implementations§
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more