pub mod dispatch;
pub mod footer;
pub mod parser;
pub mod rules;
use crate::context::AppContext;
use crate::protocol::Response;
use crate::sandbox_spawn::{native_sandbox_enforced, AuthenticatedPrincipal};
pub trait RewriteRule: Send + Sync {
fn name(&self) -> &'static str;
fn matches(&self, command: &str) -> bool;
fn rewrite(
&self,
command: &str,
session_id: Option<&str>,
ctx: &AppContext,
) -> Result<Response, String>;
}
pub fn try_rewrite(
command: &str,
session_id: Option<&str>,
ctx: &AppContext,
principal: &AuthenticatedPrincipal,
) -> Option<Response> {
if native_sandbox_enforced(ctx, principal) {
return None;
}
dispatch::dispatch(command, session_id, ctx)
}