Struct NullGraph

Source
pub struct NullGraph(/* private fields */);

Implementations§

Source§

impl NullGraph

Source

pub fn new_err<A>(args: A) -> PyErr
where A: PyErrArguments + Send + Sync + 'static,

Methods from Deref<Target = PyAny>§

Source

pub fn downcast<T>(&self) -> Result<&T, PyDowncastError<'_>>
where T: for<'py> PyTryFrom<'py>,

Convert this PyAny to a concrete Python type.

Source

pub fn hasattr<N>(&self, attr_name: N) -> Result<bool, PyErr>
where N: ToPyObject,

Determines whether this object has the given attribute.

This is equivalent to the Python expression hasattr(self, attr_name).

Source

pub fn getattr<N>(&self, attr_name: N) -> Result<&PyAny, PyErr>
where N: ToPyObject,

Retrieves an attribute value.

This is equivalent to the Python expression self.attr_name.

Source

pub fn setattr<N, V>(&self, attr_name: N, value: V) -> Result<(), PyErr>

Sets an attribute value.

This is equivalent to the Python expression self.attr_name = value.

Source

pub fn delattr<N>(&self, attr_name: N) -> Result<(), PyErr>
where N: ToPyObject,

Deletes an attribute.

This is equivalent to the Python expression del self.attr_name.

Source

pub fn compare<O>(&self, other: O) -> Result<Ordering, PyErr>
where O: ToPyObject,

Compares two Python objects.

This is equivalent to:

if self == other:
    return Equal
elif a < b:
    return Less
elif a > b:
    return Greater
else:
    raise TypeError("PyAny::compare(): All comparisons returned false")
Source

pub fn rich_compare<O>( &self, other: O, compare_op: CompareOp, ) -> Result<&PyAny, PyErr>
where O: ToPyObject,

Compares two Python objects.

Depending on the value of compare_op, this is equivalent to one of the following Python expressions:

  • CompareOp::Eq: self == other
  • CompareOp::Ne: self != other
  • CompareOp::Lt: self < other
  • CompareOp::Le: self <= other
  • CompareOp::Gt: self > other
  • CompareOp::Ge: self >= other
Source

pub fn is_callable(&self) -> bool

Determines whether this object is callable.

Source

pub fn call( &self, args: impl IntoPy<Py<PyTuple>>, kwargs: Option<&PyDict>, ) -> Result<&PyAny, PyErr>

Calls the object.

This is equivalent to the Python expression self(*args, **kwargs).

Source

pub fn call0(&self) -> Result<&PyAny, PyErr>

Calls the object without arguments.

This is equivalent to the Python expression self().

Source

pub fn call1(&self, args: impl IntoPy<Py<PyTuple>>) -> Result<&PyAny, PyErr>

Calls the object with only positional arguments.

This is equivalent to the Python expression self(*args).

Source

pub fn call_method( &self, name: &str, args: impl IntoPy<Py<PyTuple>>, kwargs: Option<&PyDict>, ) -> Result<&PyAny, PyErr>

Calls a method on the object.

This is equivalent to the Python expression self.name(*args, **kwargs).

§Example
use pyo3::types::IntoPyDict;

let gil = Python::acquire_gil();
let py = gil.python();
let list = vec![3, 6, 5, 4, 7].to_object(py);
let dict = vec![("reverse", true)].into_py_dict(py);
list.call_method(py, "sort", (), Some(dict)).unwrap();
assert_eq!(list.extract::<Vec<i32>>(py).unwrap(), vec![7, 6, 5, 4, 3]);

let new_element = 1.to_object(py);
list.call_method(py, "append", (new_element,), None).unwrap();
assert_eq!(list.extract::<Vec<i32>>(py).unwrap(), vec![7, 6, 5, 4, 3, 1]);
Source

pub fn call_method0(&self, name: &str) -> Result<&PyAny, PyErr>

Calls a method on the object without arguments.

This is equivalent to the Python expression self.name().

Source

pub fn call_method1( &self, name: &str, args: impl IntoPy<Py<PyTuple>>, ) -> Result<&PyAny, PyErr>

Calls a method on the object with only positional arguments.

This is equivalent to the Python expression self.name(*args).

Source

pub fn is_true(&self) -> Result<bool, PyErr>

Returns whether the object is considered to be true.

This is equivalent to the Python expression bool(self).

Source

pub fn is_none(&self) -> bool

Returns whether the object is considered to be None.

This is equivalent to the Python expression self is None.

Source

pub fn is_empty(&self) -> Result<bool, PyErr>

Returns true if the sequence or mapping has a length of 0.

This is equivalent to the Python expression len(self) == 0.

Source

pub fn get_item<K>(&self, key: K) -> Result<&PyAny, PyErr>

Gets an item from the collection.

This is equivalent to the Python expression self[key].

Source

pub fn set_item<K, V>(&self, key: K, value: V) -> Result<(), PyErr>

Sets a collection item value.

This is equivalent to the Python expression self[key] = value.

Source

pub fn del_item<K>(&self, key: K) -> Result<(), PyErr>

Deletes an item from the collection.

This is equivalent to the Python expression del self[key].

Source

pub fn iter(&self) -> Result<PyIterator<'_>, PyErr>

Takes an object and returns an iterator for it.

This is typically a new iterator but if the argument is an iterator, this returns itself.

Source

pub fn get_type(&self) -> &PyType

Returns the Python type object for this object’s type.

Source

pub fn get_type_ptr(&self) -> *mut PyTypeObject

Returns the Python type pointer for this object.

Source

pub fn cast_as<'a, D>(&'a self) -> Result<&'a D, PyDowncastError<'a>>
where D: PyTryFrom<'a>,

Casts the PyObject to a concrete Python object type.

This can cast only to native Python types, not types implemented in Rust.

Source

pub fn extract<'a, D>(&'a self) -> Result<D, PyErr>
where D: FromPyObject<'a>,

Extracts some type from the Python object.

This is a wrapper function around FromPyObject::extract().

Source

pub fn get_refcnt(&self) -> isize

Returns the reference count for the Python object.

Source

pub fn repr(&self) -> Result<&PyString, PyErr>

Computes the “repr” representation of self.

This is equivalent to the Python expression repr(self).

Source

pub fn str(&self) -> Result<&PyString, PyErr>

Computes the “str” representation of self.

This is equivalent to the Python expression str(self).

Source

pub fn hash(&self) -> Result<isize, PyErr>

Retrieves the hash code of self.

This is equivalent to the Python expression hash(obi).

Source

pub fn len(&self) -> Result<usize, PyErr>

Returns the length of the sequence or mapping.

This is equivalent to the Python expression len(self).

Source

pub fn dir(&self) -> &PyList

Returns the list of attributes of this object.

This is equivalent to the Python expression dir(self).

Trait Implementations§

Source§

impl AsPyPointer for NullGraph

Source§

fn as_ptr(&self) -> *mut PyObject

Gets the underlying FFI pointer, returns a borrowed pointer.

Source§

impl AsRef<PyAny> for NullGraph

Source§

fn as_ref(&self) -> &PyAny

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for NullGraph

Source§

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

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

impl Deref for NullGraph

Source§

type Target = PyAny

The resulting type after dereferencing.
Source§

fn deref(&self) -> &PyAny

Dereferences the value.
Source§

impl Display for NullGraph

Source§

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

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

impl Error for NullGraph

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<'a> From<&'a NullGraph> for &'a PyAny

Source§

fn from(ob: &'a NullGraph) -> Self

Converts to this type from the input type.
Source§

impl From<&NullGraph> for Py<NullGraph>

Source§

fn from(other: &NullGraph) -> Self

Converts to this type from the input type.
Source§

impl From<&NullGraph> for PyErr

Source§

fn from(err: &NullGraph) -> PyErr

Converts to this type from the input type.
Source§

impl<'py> FromPyObject<'py> for &'py NullGraph

Source§

fn extract(obj: &'py PyAny) -> PyResult<Self>

Extracts Self from the source PyObject.
Source§

impl IntoPy<Py<NullGraph>> for &NullGraph

Source§

fn into_py(self, py: Python<'_>) -> Py<NullGraph>

Performs the conversion.
Source§

impl PartialEq for NullGraph

Source§

fn eq(&self, o: &NullGraph) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PyLayout<NullGraph> for PyBaseExceptionObject

Source§

const IS_NATIVE_TYPE: bool = true

Source§

fn get_super(&mut self) -> Option<&mut <T as PyTypeInfo>::BaseLayout>

Source§

unsafe fn py_init(&mut self, _value: T)

Source§

unsafe fn py_drop(&mut self, _py: Python<'_>)

Source§

impl PyNativeType for NullGraph

Source§

fn py(&self) -> Python<'_>

Source§

unsafe fn unchecked_downcast(obj: &PyAny) -> &Self

Cast &PyAny to &Self without no type checking. Read more
Source§

impl PyTypeInfo for NullGraph

Source§

const NAME: &'static str = "NullGraph"

Class name
Source§

const MODULE: Option<&'static str>

Module name, if any
Source§

type Type = ()

Type of objects to store in PyObject struct
Source§

type BaseType = PyAny

Base class
Source§

type Layout = PyBaseExceptionObject

Layout
Source§

type BaseLayout = PyObject

Layout of Basetype.
Source§

type Initializer = PyNativeTypeInitializer<NullGraph>

Initializer for layout
Source§

type AsRefTarget = NullGraph

Utility type to make Py::as_ref work
Source§

fn type_object_raw(_py: Python<'_>) -> *mut PyTypeObject

PyTypeObject instance for this type.
Source§

fn is_instance(ptr: &PyAny) -> bool

Check if *mut ffi::PyObject is instance of this type
Source§

const DESCRIPTION: &'static str = "\0"

Class doc string
Source§

const FLAGS: usize = 0usize

Type flags (ie PY_TYPE_FLAG_GC, PY_TYPE_FLAG_WEAKREF)
Source§

fn is_exact_instance(object: &PyAny) -> bool

Check if *mut ffi::PyObject is exact instance of this type
Source§

impl ToPyObject for NullGraph

Source§

fn to_object(&self, py: Python<'_>) -> PyObject

Converts self into a Python object.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'p, T> FromPyPointer<'p> for T
where T: 'p + PyNativeType,

Source§

unsafe fn from_owned_ptr_or_opt( py: Python<'p>, ptr: *mut PyObject, ) -> Option<&'p T>

Source§

unsafe fn from_borrowed_ptr_or_opt( _py: Python<'p>, ptr: *mut PyObject, ) -> Option<&'p T>

Source§

unsafe fn from_owned_ptr_or_panic( py: Python<'p>, ptr: *mut PyObject, ) -> &'p Self

Source§

unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut PyObject) -> &'p Self

Source§

unsafe fn from_owned_ptr_or_err( py: Python<'p>, ptr: *mut PyObject, ) -> Result<&'p Self, PyErr>

Source§

unsafe fn from_borrowed_ptr_or_panic( py: Python<'p>, ptr: *mut PyObject, ) -> &'p Self

Source§

unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut PyObject) -> &'p Self

Source§

unsafe fn from_borrowed_ptr_or_err( py: Python<'p>, ptr: *mut PyObject, ) -> Result<&'p Self, PyErr>

Source§

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<'v, T> PyTryFrom<'v> for T

Source§

fn try_from<V>(value: V) -> Result<&'v T, PyDowncastError<'v>>
where V: Into<&'v PyAny>,

Cast from a concrete Python object type to PyObject.
Source§

fn try_from_exact<V>(value: V) -> Result<&'v T, PyDowncastError<'v>>
where V: Into<&'v PyAny>,

Cast from a concrete Python object type to PyObject. With exact type check.
Source§

unsafe fn try_from_unchecked<V>(value: V) -> &'v T
where V: Into<&'v PyAny>,

Cast a PyAny to a specific type of PyObject. The caller must have already verified the reference is for this type.
Source§

impl<T> PyTypeObject for T
where T: PyTypeInfo,

Source§

fn type_object(py: Python<'_>) -> &PyType

Returns the safe abstraction over the type object.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToBorrowedObject for T
where T: ToPyObject,

Source§

fn with_borrowed_ptr<F, R>(&self, py: Python<'_>, f: F) -> R
where F: FnOnce(*mut PyObject) -> R,

Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
Source§

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

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V