pub struct Client { /* private fields */ }Expand description
Typed client for the AIRL HTTP API.
Construct with Client::new and chain optional configuration
methods like Client::with_auth_token and Client::with_timeout.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Create a new client pointing at the given API server base URL
(e.g. "http://127.0.0.1:9090").
Sourcepub fn with_auth_token(self, token: impl Into<String>) -> Self
pub fn with_auth_token(self, token: impl Into<String>) -> Self
Set a Bearer token to send with every request.
Required when the server was started via serve_with_auth.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Override the default 30-second request timeout.
Sourcepub fn create_project(
&self,
name: impl Into<String>,
module_json: impl Into<String>,
) -> Result<ProjectInfo, SdkError>
pub fn create_project( &self, name: impl Into<String>, module_json: impl Into<String>, ) -> Result<ProjectInfo, SdkError>
Create a project from a JSON IR string. Equivalent to POST /project/create.
Sourcepub fn get_project(&self) -> Result<ProjectInfo, SdkError>
pub fn get_project(&self) -> Result<ProjectInfo, SdkError>
Get project metadata. Equivalent to GET /project.
Sourcepub fn get_module(&self) -> Result<ModuleResponse, SdkError>
pub fn get_module(&self) -> Result<ModuleResponse, SdkError>
Fetch the current module IR. Equivalent to GET /module.
Sourcepub fn apply_patch(
&self,
patch: &Patch,
) -> Result<PatchResultResponse, SdkError>
pub fn apply_patch( &self, patch: &Patch, ) -> Result<PatchResultResponse, SdkError>
Apply a semantic patch. Equivalent to POST /patch/apply.
The server expects the patch fields at the request body root
(thanks to #[serde(flatten)] on the request struct), so we send
the patch as-is.
Sourcepub fn preview_patch(
&self,
patch: &Patch,
) -> Result<PatchPreviewResponse, SdkError>
pub fn preview_patch( &self, patch: &Patch, ) -> Result<PatchPreviewResponse, SdkError>
Preview a patch (dry-run). Equivalent to POST /patch/preview.
Sourcepub fn undo_patch(&self) -> Result<PatchResultResponse, SdkError>
pub fn undo_patch(&self) -> Result<PatchResultResponse, SdkError>
Undo the most recent patch. Equivalent to POST /patch/undo.
Sourcepub fn typecheck(&self) -> Result<TypeCheckResponse, SdkError>
pub fn typecheck(&self) -> Result<TypeCheckResponse, SdkError>
Type-check the current module. Equivalent to POST /typecheck.
Sourcepub fn check_constraints(
&self,
constraints: &[Constraint],
) -> Result<ConstraintsResponse, SdkError>
pub fn check_constraints( &self, constraints: &[Constraint], ) -> Result<ConstraintsResponse, SdkError>
Check the module against architectural constraints.
Equivalent to POST /constraints/check.
Sourcepub fn diff(
&self,
other_module_json: impl Into<String>,
) -> Result<ModuleDiff, SdkError>
pub fn diff( &self, other_module_json: impl Into<String>, ) -> Result<ModuleDiff, SdkError>
Diff the current module against another module (passed as JSON).
Equivalent to POST /diff.
Sourcepub fn interpret(
&self,
limits: InterpretLimits,
) -> Result<InterpretResponse, SdkError>
pub fn interpret( &self, limits: InterpretLimits, ) -> Result<InterpretResponse, SdkError>
Interpret the module with custom limits. Equivalent to POST /interpret.
Sourcepub fn interpret_default(&self) -> Result<InterpretResponse, SdkError>
pub fn interpret_default(&self) -> Result<InterpretResponse, SdkError>
Interpret the module with default limits (1M steps, 1000 call depth).
Sourcepub fn compile(&self) -> Result<CompileResponse, SdkError>
pub fn compile(&self) -> Result<CompileResponse, SdkError>
Cranelift JIT compile and run the module. Equivalent to POST /compile.
Sourcepub fn compile_wasm(&self) -> Result<Vec<u8>, SdkError>
pub fn compile_wasm(&self) -> Result<Vec<u8>, SdkError>
Compile the module to a WASM binary. Equivalent to POST /compile/wasm.
Returns raw bytes.
Sourcepub fn find_functions(
&self,
pattern: &str,
) -> Result<Vec<FuncSummary>, SdkError>
pub fn find_functions( &self, pattern: &str, ) -> Result<Vec<FuncSummary>, SdkError>
Find functions whose name contains pattern (substring match).
Equivalent to GET /query/functions?pattern=<p>.
Sourcepub fn get_call_graph(&self, func: &str) -> Result<Vec<CallEdge>, SdkError>
pub fn get_call_graph(&self, func: &str) -> Result<Vec<CallEdge>, SdkError>
Get call-graph edges for a function.
Equivalent to GET /query/call-graph?func=<name>.
Sourcepub fn get_effects(&self, func: &str) -> Result<EffectSummary, SdkError>
pub fn get_effects(&self, func: &str) -> Result<EffectSummary, SdkError>
Get the declared effect set for a function.
Equivalent to GET /query/effects?func=<name>.
Sourcepub fn find_dead_code(&self, entry: &str) -> Result<DeadCodeReport, SdkError>
pub fn find_dead_code(&self, entry: &str) -> Result<DeadCodeReport, SdkError>
Find functions unreachable from an entry point (default "main").
Equivalent to GET /query/dead-code?entry=<name>.
Sourcepub fn builtin_usage(&self) -> Result<BuiltinUsage, SdkError>
pub fn builtin_usage(&self) -> Result<BuiltinUsage, SdkError>
Count calls to each std::... builtin across the module.
Equivalent to GET /query/builtin-usage.
Sourcepub fn effect_surface(&self) -> Result<EffectSurface, SdkError>
pub fn effect_surface(&self) -> Result<EffectSurface, SdkError>
Get the effect surface of the module.
Equivalent to GET /query/effect-surface.
Sourcepub fn project_to_text(
&self,
lang: ProjectionLang,
) -> Result<TextProjectionResponse, SdkError>
pub fn project_to_text( &self, lang: ProjectionLang, ) -> Result<TextProjectionResponse, SdkError>
Render the module in a target language.
Equivalent to POST /project/text { language }.