Skip to main content

Session

Trait Session 

Source
pub trait Session:
    Send
    + Sync
    + 'static {
    // Required method
    fn fetch(
        &self,
        request: &Request<Bytes>,
    ) -> impl Future<Output = Result<Response<Bytes>, Error>> + Send;

    // Provided method
    fn document(&self) -> Option<&dyn Document> { ... }
}
Expand description

Fetches one request using a backend’s resources.

A successful fetch returns a complete response with an immutable Bytes body. HTTP sessions return the received bytes; browser sessions return an HTML snapshot captured after navigation. A live browser document is a separate optional capability, accessed through Self::document. Context caches the first successful response.

Required Methods§

Source

fn fetch( &self, request: &Request<Bytes>, ) -> impl Future<Output = Result<Response<Bytes>, Error>> + Send

Fetches request, returning its status, headers, final URI and body.

§Errors

Returns an error if fetching, status checking or reading the body fails.

Provided Methods§

Source

fn document(&self) -> Option<&dyn Document>

Returns the live document capability, if this session has a DOM.

This reports support, not navigation state. Operations on the document may fail before a page is fetched. Fetch through the context before querying it; capture failures must not silently fall back to parsing the response snapshot.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§