Skip to main content

Client

Struct Client 

Source
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

Source

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").

Source

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.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Override the default 30-second request timeout.

Source

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.

Source

pub fn get_project(&self) -> Result<ProjectInfo, SdkError>

Get project metadata. Equivalent to GET /project.

Source

pub fn get_module(&self) -> Result<ModuleResponse, SdkError>

Fetch the current module IR. Equivalent to GET /module.

Source

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.

Source

pub fn preview_patch( &self, patch: &Patch, ) -> Result<PatchPreviewResponse, SdkError>

Preview a patch (dry-run). Equivalent to POST /patch/preview.

Source

pub fn undo_patch(&self) -> Result<PatchResultResponse, SdkError>

Undo the most recent patch. Equivalent to POST /patch/undo.

Source

pub fn typecheck(&self) -> Result<TypeCheckResponse, SdkError>

Type-check the current module. Equivalent to POST /typecheck.

Source

pub fn check_constraints( &self, constraints: &[Constraint], ) -> Result<ConstraintsResponse, SdkError>

Check the module against architectural constraints. Equivalent to POST /constraints/check.

Source

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.

Source

pub fn interpret( &self, limits: InterpretLimits, ) -> Result<InterpretResponse, SdkError>

Interpret the module with custom limits. Equivalent to POST /interpret.

Source

pub fn interpret_default(&self) -> Result<InterpretResponse, SdkError>

Interpret the module with default limits (1M steps, 1000 call depth).

Source

pub fn compile(&self) -> Result<CompileResponse, SdkError>

Cranelift JIT compile and run the module. Equivalent to POST /compile.

Source

pub fn compile_wasm(&self) -> Result<Vec<u8>, SdkError>

Compile the module to a WASM binary. Equivalent to POST /compile/wasm. Returns raw bytes.

Source

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>.

Source

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>.

Source

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>.

Source

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>.

Source

pub fn builtin_usage(&self) -> Result<BuiltinUsage, SdkError>

Count calls to each std::... builtin across the module. Equivalent to GET /query/builtin-usage.

Source

pub fn effect_surface(&self) -> Result<EffectSurface, SdkError>

Get the effect surface of the module. Equivalent to GET /query/effect-surface.

Source

pub fn project_to_text( &self, lang: ProjectionLang, ) -> Result<TextProjectionResponse, SdkError>

Render the module in a target language. Equivalent to POST /project/text { language }.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.