Struct aws_smithy_http_server_python::context::PyContext
source · pub struct PyContext { /* private fields */ }
Expand description
PyContext is a wrapper for context object provided by the user. It injects some values (currently only super::lambda::PyLambdaContext) that is type-hinted by the user.
PyContext is initialised during the startup, it inspects the provided context object for fields that are type-hinted to inject some values provided by the framework (see PyContext::new()).
After finding fields that needs to be injected, layer::AddPyContextLayer, a [tower::Layer], populates request-scoped values from incoming request.
And finally PyContext implements [ToPyObject] (so it can by passed to Python handlers) that provides [PyObject] provided by the user with the additional values injected by the framework.
Implementations§
source§impl PyContext
impl PyContext
pub fn new(inner: PyObject) -> PyResult<Self>
pub fn populate_from_extensions(&self, _ext: &Extensions)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PyContext
impl !RefUnwindSafe for PyContext
impl Send for PyContext
impl Sync for PyContext
impl Unpin for PyContext
impl UnwindSafe for PyContext
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreCreates a shared type from an unshared type.
§impl<T> ToBorrowedObject for Twhere
T: ToPyObject,
impl<T> ToBorrowedObject for Twhere
T: ToPyObject,
§fn with_borrowed_ptr<F, R>(&self, py: Python<'_>, f: F) -> R
fn with_borrowed_ptr<F, R>(&self, py: Python<'_>, f: F) -> R
👎Deprecated since 0.17.0: this trait is no longer used by PyO3, use ToPyObject or IntoPy<PyObject>
Converts self into a Python object and calls the specified closure
on the native FFI pointer underlying the Python object. Read more