pub struct Session { /* private fields */ }
Expand description

Data specific to an individual request, including any host-side allocations on behalf of the guest processing the request.

Implementations§

source§

impl Session

source

pub fn new( req_id: u64, req: Request<Body>, resp_sender: Sender<Response<Body>>, client_ip: IpAddr, backends: Arc<Backends>, device_detection: Arc<DeviceDetection>, geolocation: Arc<Geolocation>, tls_config: TlsConfig, dictionaries: Arc<Dictionaries>, config_path: Arc<Option<PathBuf>>, object_store: Arc<ObjectStores>, secret_stores: Arc<SecretStores> ) -> Session

Create an empty session.

source

pub fn downstream_client_ip(&self) -> &IpAddr

Retrieve the downstream client IP address associated with this session.

source

pub fn downstream_request(&self) -> RequestHandle

Retrieve the handle corresponding to the downstream request.

source

pub fn downstream_request_body(&self) -> BodyHandle

Retrieve the handle corresponding to the downstream request body.

source

pub fn downstream_original_headers(&self) -> &HeaderMap

Access the header map that was copied from the original downstream request.

source

pub fn send_downstream_response( &mut self, resp: Response<Body> ) -> Result<(), Error>

Send the downstream response.

Yield an error if a response has already been sent.

§Panics

This method must only be called once, after a channel has been opened with Session::set_downstream_response_sender, and before the associated oneshot::Receiver has been dropped.

This method will panic if:

  • the downstream response channel was never opened
  • the associated receiver was dropped prematurely
source

pub fn close_downstream_response_sender(&mut self)

Close the downstream response sender, potentially without sending any response.

source

pub fn insert_body(&mut self, body: Body) -> BodyHandle

Insert a Body into the session.

This method returns the BodyHandle, which can then be used to access and mutate the response parts.

source

pub fn body(&self, handle: BodyHandle) -> Result<&Body, HandleError>

Get a reference to a Body, given its BodyHandle.

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn body_mut(&mut self, handle: BodyHandle) -> Result<&mut Body, HandleError>

Get a mutable reference to a Body, given its BodyHandle.

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn take_body(&mut self, handle: BodyHandle) -> Result<Body, HandleError>

Take ownership of a Body, given its BodyHandle.

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn drop_body(&mut self, handle: BodyHandle) -> Result<(), HandleError>

Drop a Body from the Session, given its [BodyHandle][crate::wiggle_abi::types::BodyHandle].

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn begin_streaming( &mut self, handle: BodyHandle ) -> Result<Body, HandleError>

Transition a normal Body into the write end of a streaming body, returning the original body with the read end appended.

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn is_streaming_body(&self, handle: BodyHandle) -> bool

Returns true if and only if the provided BodyHandle is the downstream body being sent.

To get a mutable reference to the streaming body Sender, see Session::streaming_body_mut.

source

pub fn streaming_body_mut( &mut self, handle: BodyHandle ) -> Result<&mut StreamingBody, HandleError>

Get a mutable reference to the streaming body Sender, if and only if the provided BodyHandle is the downstream body being sent.

To check if a handle is the currently-streaming downstream response body, see Session::is_streaming_body.

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn take_streaming_body( &mut self, handle: BodyHandle ) -> Result<StreamingBody, HandleError>

Take ownership of a streaming body Sender, if and only if the provided BodyHandle is the downstream body being sent.

To check if a handle is the currently-streaming downstream response body, see Session::is_streaming_body.

Returns a HandleError if the handle is not associated with a body in the session.

source

pub fn insert_request_parts(&mut self, parts: Parts) -> RequestHandle

Insert the Parts of a Request into the session.

This method returns a new RequestHandle, which can then be used to access and mutate the request parts.

source

pub fn request_parts( &self, handle: RequestHandle ) -> Result<&Parts, HandleError>

Get a reference to the Parts of a Request, given its RequestHandle.

Returns a HandleError if the handle is not associated with a request in the session.

source

pub fn request_parts_mut( &mut self, handle: RequestHandle ) -> Result<&mut Parts, HandleError>

Get a mutable reference to the Parts of a Request, given its RequestHandle.

Returns a HandleError if the handle is not associated with a request in the session.

source

pub fn take_request_parts( &mut self, handle: RequestHandle ) -> Result<Parts, HandleError>

Take ownership of the Parts of a Request, given its RequestHandle.

Returns a HandleError if the handle is not associated with a request in the session.

source

pub fn insert_response_parts(&mut self, parts: Parts) -> ResponseHandle

Insert the Parts of a Response into the session.

This method returns a new ResponseHandle, which can then be used to access and mutate the response parts.

source

pub fn response_parts( &self, handle: ResponseHandle ) -> Result<&Parts, HandleError>

Get a reference to the Parts of a Response, given its ResponseHandle.

Returns a HandleError if the handle is not associated with a response in the session.

source

pub fn response_parts_mut( &mut self, handle: ResponseHandle ) -> Result<&mut Parts, HandleError>

Get a mutable reference to the Parts of a Response, given its ResponseHandle.

Returns a HandleError if the handle is not associated with a response in the session.

source

pub fn take_response_parts( &mut self, handle: ResponseHandle ) -> Result<Parts, HandleError>

Take ownership of the Parts of a Response, given its ResponseHandle.

Returns a HandleError if the handle is not associated with a response in the session.

source

pub fn insert_response( &mut self, resp: Response<Body> ) -> (ResponseHandle, BodyHandle)

source

pub fn log_endpoint_handle(&mut self, name: &[u8]) -> EndpointHandle

Get an EndpointHandle from the session, corresponding to the provided endpoint name. A new backing LogEndpoint will be created if one does not already exist.

source

pub fn log_endpoint( &self, handle: EndpointHandle ) -> Result<&LogEndpoint, HandleError>

Get a reference to a LogEndpoint, given its EndpointHandle.

Returns a HandleError if the handle is not associated with an endpoint in the session.

source

pub fn backend(&self, name: &str) -> Option<&Arc<Backend>>

Look up a backend by name.

source

pub fn dynamic_backend(&self, name: &str) -> Option<&Arc<Backend>>

Look up a dynamic backend (only) by name.

source

pub fn backend_names(&self) -> impl Iterator<Item = &String>

Return the full list of static and dynamic backend names as an Iterator.

source

pub fn add_backend(&mut self, name: &str, info: Backend) -> bool

Try to add a backend with the given name prefix to our set of current backends. Upon success, return true. If the name already exists somewhere, return false; the caller should signal an appropriate error.

source

pub fn tls_config(&self) -> &TlsConfig

Access the TLS configuration.

source

pub fn device_detection_lookup(&self, user_agent: &str) -> Option<String>

source

pub fn dictionary_handle( &mut self, name: &str ) -> Result<DictionaryHandle, Error>

Look up a dictionary-handle by name.

source

pub fn dictionary( &self, handle: DictionaryHandle ) -> Result<&Dictionary, HandleError>

Look up a dictionary by dictionary-handle.

source

pub fn dictionaries(&self) -> &Arc<Dictionaries>

Access the dictionary map.

source

pub fn geolocation_lookup(&self, addr: &IpAddr) -> Option<String>

source

pub fn obj_store_handle( &mut self, key: &str ) -> Result<ObjectStoreHandle, Error>

source

pub fn get_obj_store_key( &self, handle: ObjectStoreHandle ) -> Option<&ObjectStoreKey>

source

pub fn obj_insert( &self, obj_store_key: ObjectStoreKey, obj_key: ObjectKey, obj: Vec<u8> ) -> Result<(), ObjectStoreError>

source

pub fn insert_pending_kv_insert( &mut self, pending: PendingKvInsertTask ) -> PendingKvInsertHandle

Insert a [PendingKvInsert] into the session.

This method returns a new [PendingKvInsertHandle], which can then be used to access and mutate the pending insert.

source

pub fn take_pending_kv_insert( &mut self, handle: PendingKvInsertHandle ) -> Result<PendingKvInsertTask, HandleError>

Take ownership of a [PendingKvInsert], given its [PendingKvInsertHandle].

Returns a HandleError if the handle is not associated with a pending insert in the session.

source

pub fn pending_kv_insert( &self, handle: PendingKvInsertHandle ) -> Result<&PendingKvInsertTask, HandleError>

Get a reference to a [PendingInsert], given its [PendingKvInsertHandle].

Returns a HandleError if the handle is not associated with a insert in the session.

source

pub fn obj_delete( &self, obj_store_key: ObjectStoreKey, obj_key: ObjectKey ) -> Result<(), ObjectStoreError>

source

pub fn insert_pending_kv_delete( &mut self, pending: PendingKvDeleteTask ) -> PendingKvDeleteHandle

Insert a [PendingKvDelete] into the session.

This method returns a new [PendingKvDeleteHandle], which can then be used to access and mutate the pending delete.

source

pub fn take_pending_kv_delete( &mut self, handle: PendingKvDeleteHandle ) -> Result<PendingKvDeleteTask, HandleError>

Take ownership of a [PendingKvDelete], given its [PendingKvDeleteHandle].

Returns a HandleError if the handle is not associated with a pending delete in the session.

source

pub fn pending_kv_delete( &self, handle: PendingKvDeleteHandle ) -> Result<&PendingKvDeleteTask, HandleError>

Get a reference to a [PendingDelete], given its [PendingKvDeleteHandle].

Returns a HandleError if the handle is not associated with a delete in the session.

source

pub fn obj_lookup( &self, obj_store_key: &ObjectStoreKey, obj_key: &ObjectKey ) -> Result<Vec<u8>, ObjectStoreError>

source

pub fn insert_pending_kv_lookup( &mut self, pending: PendingKvLookupTask ) -> PendingKvLookupHandle

Insert a [PendingLookup] into the session.

This method returns a new [PendingKvLookupHandle], which can then be used to access and mutate the pending lookup.

source

pub fn take_pending_kv_lookup( &mut self, handle: PendingKvLookupHandle ) -> Result<PendingKvLookupTask, HandleError>

Take ownership of a [PendingLookup], given its [PendingKvLookupHandle].

Returns a HandleError if the handle is not associated with a pending lookup in the session.

source

pub fn pending_kv_lookup( &self, handle: PendingKvLookupHandle ) -> Result<&PendingKvLookupTask, HandleError>

Get a reference to a [PendingLookup], given its [PendingKvLookupHandle].

Returns a HandleError if the handle is not associated with a lookup in the session.

source

pub fn secret_store_handle(&mut self, name: &str) -> Option<SecretStoreHandle>

source

pub fn secret_store_name(&self, handle: SecretStoreHandle) -> Option<String>

source

pub fn secret_handle( &mut self, store_name: &str, secret_name: &str ) -> Option<SecretHandle>

source

pub fn secret_lookup(&self, handle: SecretHandle) -> Option<SecretLookup>

source

pub fn add_secret(&mut self, plaintext: Vec<u8>) -> SecretHandle

source

pub fn secret_stores(&self) -> &Arc<SecretStores>

source

pub fn insert_pending_request( &mut self, pending: PeekableTask<Response<Body>> ) -> PendingRequestHandle

Insert a [PendingRequest] into the session.

This method returns a new [PendingRequestHandle], which can then be used to access and mutate the pending request.

source

pub fn pending_request( &self, handle: PendingRequestHandle ) -> Result<&PeekableTask<Response<Body>>, HandleError>

Get a reference to a [PendingRequest], given its [PendingRequestHandle].

Returns a HandleError if the handle is not associated with a request in the session.

source

pub fn pending_request_mut( &mut self, handle: PendingRequestHandle ) -> Result<&mut PeekableTask<Response<Body>>, HandleError>

Get a mutable reference to a [PendingRequest], given its [PendingRequestHandle].

Returns a HandleError if the handle is not associated with a request in the session.

source

pub fn take_pending_request( &mut self, handle: PendingRequestHandle ) -> Result<PeekableTask<Response<Body>>, HandleError>

Take ownership of a [PendingRequest], given its [PendingRequestHandle].

Returns a HandleError if the handle is not associated with a pending request in the session.

source

pub fn reinsert_pending_request( &mut self, handle: PendingRequestHandle, pending_req: PeekableTask<Response<Body>> ) -> Result<(), HandleError>

source

pub fn prepare_select_targets( &mut self, handles: impl IntoIterator<Item = AsyncItemHandle> ) -> Result<Vec<SelectTarget>, HandleError>

Take ownership of multiple [PendingRequest]s in preparation for a select.

Returns a HandleError if any of the handles are not associated with a pending request in the session.

source

pub fn reinsert_select_targets(&mut self, targets: Vec<SelectTarget>)

Put the given vector of select targets back into the pending request table, using the handles stored within each [SelectTarget].

source

pub fn req_id(&self) -> u64

Returns the unique identifier for the request this session is processing.

source

pub fn config_path(&self) -> &Arc<Option<PathBuf>>

Access the path to the configuration file for this invocation.

source

pub fn async_item_mut( &mut self, handle: AsyncItemHandle ) -> Result<&mut AsyncItem, HandleError>

source

pub fn take_async_item( &mut self, handle: AsyncItemHandle ) -> Result<AsyncItem, HandleError>

source

pub async fn select_impl( &mut self, handles: impl IntoIterator<Item = AsyncItemHandle> ) -> Result<usize, Error>

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

source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

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

§

type Pointer = u32

source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more