Skip to main content

RequestView

Trait RequestView 

Source
pub trait RequestView {
    // Required method
    fn query(&self) -> Option<&str>;

    // Provided methods
    fn is_read_only(&self) -> bool { ... }
    fn database(&self) -> Option<&str> { ... }
    fn client_id(&self) -> Option<&str> { ... }
    fn tenant_id(&self) -> Option<&str> { ... }
}
Expand description

Read-only view of per-request metadata.

Every method returns Option where appropriate so implementations can return None when the underlying carrier doesn’t track that field. Consumers that need a field unconditionally should guard with .ok_or(Error::…) at the call site.

Required Methods§

Source

fn query(&self) -> Option<&str>

SQL text of the query being processed, if this request carries a query. Returns None for non-SQL protocol messages (e.g. Terminate, Sync) or for contexts that don’t carry SQL.

Provided Methods§

Source

fn is_read_only(&self) -> bool

Whether the query is a read-only operation (SELECT / SHOW / …). Defaults to false for safety — an implementation that cannot classify a query should leave the default.

Source

fn database(&self) -> Option<&str>

Target database from the client’s startup message.

Source

fn client_id(&self) -> Option<&str>

Stable client session identifier.

Source

fn tenant_id(&self) -> Option<&str>

Tenant identifier, for multi-tenant deployments.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl RequestView for QueryContext

Available on crate feature wasm-plugins only.