pub trait Policy:
Sized
+ Send
+ Sync
+ 'static {
type Refusal: HostError;
type Failure: HostError + Clone + From<EngineFailure<Self::Failure, Self::Refusal>>;
type Scope;
// Required methods
fn judge(&self, action: &PolicyAction<'_>) -> Result<(), Self::Refusal>;
fn check_sql(&self, tokens: &[Token]) -> Result<(), Self::Refusal>;
fn begin_app_call(&self);
fn host_object(&self, name: &str) -> bool;
fn statement_key(&self) -> u64;
fn enter(&self, scope: &Self::Scope);
fn leave(&self, scope: &Self::Scope);
fn refresh(&self, sql: &HostSql<Self>, extent: Refresh) -> Result<()>;
}Expand description
What the host adds to the authorizer’s rules.
Required Associated Types§
Required Methods§
Sourcefn judge(&self, action: &PolicyAction<'_>) -> Result<(), Self::Refusal>
fn judge(&self, action: &PolicyAction<'_>) -> Result<(), Self::Refusal>
Judge an action the authorizer’s rules allowed; Err refuses the
statement with it. A host statement’s actions come here too, so the
policy sees every action allowed.
Sourcefn check_sql(&self, tokens: &[Token]) -> Result<(), Self::Refusal>
fn check_sql(&self, tokens: &[Token]) -> Result<(), Self::Refusal>
Judge an app statement’s text before it is prepared.
Sourcefn begin_app_call(&self)
fn begin_app_call(&self)
A new app call begins: forget what the last statement left.
Sourcefn host_object(&self, name: &str) -> bool
fn host_object(&self, name: &str) -> bool
Whether name, a trigger or view, is the host’s own object.
Sourcefn statement_key(&self) -> u64
fn statement_key(&self) -> u64
What the policy adds to the app statement cache’s key.
Sourcefn leave(&self, scope: &Self::Scope)
fn leave(&self, scope: &Self::Scope)
Work in scope ended, on any path out of it, a panic’s included.
Sourcefn refresh(&self, sql: &HostSql<Self>, extent: Refresh) -> Result<()>
fn refresh(&self, sql: &HostSql<Self>, extent: Refresh) -> Result<()>
Read again what the policy keeps of the connection’s schema: all of
it, or what changed since it last read. The connection calls it with
Refresh::Whole as it opens and with Refresh::Changed before each
app statement, and the host through refresh_policy.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".