# pyo3::conversion::AsPyPointer - Rust
This trait represents that we can do zero-cost conversion from the object to a FFI pointer.
Keywords: rust, rustlang, rust-lang, AsPyPointer

# Trait pyo3::conversion::AsPyPointer [−] [src]

    pub trait AsPyPointer {
        fn as_ptr(&self) -> *mut PyObject;
    }

This trait represents that we can do zero-cost conversion from the object to a FFI pointer.

This trait is implemented for types that internally wrap a pointer to a Python object.

# Example

    use pyo3::{AsPyPointer, prelude::*};
    let gil = Python::acquire_gil();
    let dict = pyo3::types::PyDict::new(gil.python());
    // All native object wrappers implement AsPyPointer!!!
    assert_ne!(dict.as_ptr(), std::ptr::null_mut());

## Required methods

### `fn as_ptr(&self) -> *mut PyObject` [src]

Retrieves the underlying FFI pointer (as a borrowed pointer).

Loading content...

## Implementations on Foreign Types

### `impl<T> AsPyPointer for Option<T> where
T: AsPyPointer,` [src]

Convert `None` into a null pointer.

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Loading content...

## Implementors

### `impl AsPyPointer for CancelledError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for IncompleteReadError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for InvalidStateError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for LimitOverrunError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for QueueEmpty` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for QueueFull` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for TimeoutError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for gaierror` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for herror` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for timeout` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyArithmeticError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyAssertionError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyAttributeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyBaseException` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyBlockingIOError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyBrokenPipeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyBufferError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyChildProcessError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyConnectionAbortedError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyConnectionError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyConnectionRefusedError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyConnectionResetError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyEOFError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyEnvironmentError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyException` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyFileExistsError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyFileNotFoundError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyFloatingPointError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyGeneratorExit` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyIOError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyImportError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyIndexError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyInterruptedError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyIsADirectoryError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyKeyError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyKeyboardInterrupt` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyLookupError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyMemoryError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyModuleNotFoundError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyNameError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyNotADirectoryError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyNotImplementedError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyOSError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyOverflowError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyPermissionError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyProcessLookupError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyRecursionError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyReferenceError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyRuntimeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyStopAsyncIteration` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyStopIteration` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PySyntaxError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PySystemError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PySystemExit` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyTimeoutError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyTypeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyUnboundLocalError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyUnicodeDecodeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyUnicodeEncodeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyUnicodeError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyUnicodeTranslateError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyValueError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyZeroDivisionError` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PanicException` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyAny` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

### `impl AsPyPointer for PyModule` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyBool` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyByteArray` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyBytes` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyCFunction` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyComplex` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyDate` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyDateTime` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyDelta` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyDict` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyFloat` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyFrozenSet` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyFunction` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyIterator` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyList` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyLong` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PySequence` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PySet` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PySlice` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyString` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyTime` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyTuple` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyType` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl AsPyPointer for PyTzInfo` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl<'a, T: PyClass> AsPyPointer for PyRef<'a, T>` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

### `impl<'a, T: PyClass> AsPyPointer for PyRefMut<'a, T>` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

### `impl<T> AsPyPointer for Py<T>` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl<T: PyClass> AsPyPointer for PyCell<T>` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Loading content...