Struct cpython::PyRustTypeBuilder [] [src]

#[must_use]
pub struct PyRustTypeBuilder<'p, T, B = PyObject> where T: 'static + Send, B: PythonBaseObject {
    // some fields omitted
}

Methods

impl<'p, T> PyRustTypeBuilder<'p, T> where T: 'static + Send
[src]

fn new(py: Python<'p>, name: &str) -> PyRustTypeBuilder<'p, T>

Create a new type builder.

py: proof that the GIL is held by the current thread. name: name of the new type

fn base<T2, B2>(self, base_type: &PyRustType<T2, B2>) -> PyRustTypeBuilder<'p, T, PyRustObject<T2, B2>> where T2: 'static + Send, B2: PythonBaseObject

Sets the base class that this type is inheriting from.

impl<'p, T, B> PyRustTypeBuilder<'p, T, B> where T: 'static + Send, B: PythonBaseObject
[src]

fn doc(self, doc_str: &str) -> Self

Set the doc string on the type being built.

fn add<M>(self, name: &str, val: M) -> Self where M: TypeMember<PyRustObject<T, B>> + 'static

Adds a new member to the type.

fn set_new<N>(self, new: N) -> Self where N: TypeConstructor

Sets the constructor (new method)

As new argument, use either the py_fn!() or the py_class_method!() macro.

fn finish(self) -> PyResult<PyRustType<T, B>>

Finalize construction of the new type.