Skip to main content

BrainHttpClient

Struct BrainHttpClient 

Source
pub struct BrainHttpClient { /* private fields */ }
Expand description

An async HTTP client for the Brain edge.

Implementations§

Source§

impl BrainHttpClient

Source

pub fn new(api_key: impl Into<String>, base_url: impl Into<String>) -> Self

Authenticate as api_key against base_url. Uses the DEFAULT_TIMEOUT request timeout and the default HttpRetryPolicy.

Key first, URL second — matching the Python and TypeScript clients, which both take the key as the required argument and the URL as the optional one. Both parameters are impl Into<String>, so a swapped call compiles cleanly and sends the base URL as the bearer token; keeping the three SDKs in one order is the only thing that makes that mistake hard. Self::localhost covers the common case in one argument.

Source

pub fn localhost(api_key: impl Into<String>) -> Self

Build a client against DEFAULT_BASE_URL.

Source

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

Override the per-request timeout (default DEFAULT_TIMEOUT). A timeout surfaces as a transport BrainHttpError, not a panic.

Source

pub fn with_retry_policy(self, policy: HttpRetryPolicy) -> Self

Override the retry policy applied to idempotent verbs (encode, whoami, capabilities). Pass HttpRetryPolicy::none to disable.

Source

pub async fn encode( &self, input: &EncodeInput, ) -> Result<EncodeResult, BrainHttpError>

Store a memory. Idempotent (stable server-side request id) — retried.

Source

pub async fn recall( &self, input: &RecallInput, ) -> Result<RecallResult, BrainHttpError>

Recall memories for a cue.

Source

pub async fn forget( &self, input: &ForgetInput, ) -> Result<ForgetResult, BrainHttpError>

Forget a memory.

Create/overwrite a directed edge between two memories.

Remove a directed edge (idempotent).

Source

pub async fn plan( &self, input: &PlanInput, ) -> Result<PlanResult, BrainHttpError>

Plan a path from a start state to a goal state.

Source

pub async fn reason( &self, input: &ReasonInput, ) -> Result<ReasonResult, BrainHttpError>

Infer over the graph from an observation.

Source

pub async fn whoami(&self) -> Result<Whoami, BrainHttpError>

The identity Brain resolves from the credential. Idempotent GET — retried.

Source

pub async fn capabilities(&self) -> Result<Capabilities, BrainHttpError>

What the connected shard supports. Idempotent GET — retried.

Source

pub async fn memory_list( &self, query: &MemoryListQuery, ) -> Result<MemoryListPage, BrainHttpError>

A page of the space’s memories. This is not a recall: no cue, no ranking, just the timeline in a stable order plus a cursor.

Source

pub async fn memory_inspect( &self, memory_id: &str, ) -> Result<MemoryInspect, BrainHttpError>

Everything the encode pipeline produced for one memory: the vector, the persisted row, the extracted graph.

Source

pub async fn list_entities( &self, query: &ListEntitiesQuery, ) -> Result<ListEntitiesResult, BrainHttpError>

Entities in the typed graph, filtered by the query.

Source

pub async fn get_entity( &self, entity_id: &str, ) -> Result<EntityDetail, BrainHttpError>

One entity by id.

Source

pub async fn list_relations( &self, entity_id: &str, query: &ListRelationsQuery, ) -> Result<ListRelationsResult, BrainHttpError>

The relations incident to one entity.

Source

pub async fn graph_fetch( &self, query: &GraphFetchQuery, ) -> Result<GraphPage, BrainHttpError>

One page of the space’s typed graph, as a node/edge set.

Source

pub async fn get_relation( &self, relation_id: &str, query: &GetRelationQuery, ) -> Result<RelationDetail, BrainHttpError>

One relation by id.

Source

pub async fn list_statements( &self, query: &ListStatementsQuery, ) -> Result<ListStatementsResult, BrainHttpError>

Statements in the typed graph, filtered by the query.

Source

pub async fn get_statement( &self, statement_id: &str, query: &GetStatementQuery, ) -> Result<StatementDetail, BrainHttpError>

One statement by id.

Source

pub async fn get_schema( &self, query: &SchemaGetQuery, ) -> Result<Schema, BrainHttpError>

The active schema document for a namespace, or a specific version of it.

Source

pub async fn validate_schema( &self, input: &SchemaValidateInput, ) -> Result<SchemaValidateResult, BrainHttpError>

Check a schema document and report what an upload would do. A dry run that changes nothing, so it is idempotent and retried.

Source

pub async fn upload_schema( &self, input: &SchemaUploadInput, ) -> Result<SchemaUploadResult, BrainHttpError>

Upload a schema document as the namespace’s next version.

Source

pub async fn replace_schema( &self, input: &SchemaReplaceInput, ) -> Result<SchemaReplaceResult, BrainHttpError>

Replace the namespace’s schema, dropping every declared row first. Irreversible, and never retried: a second attempt would drop what the first one just wrote.

Source

pub async fn create_entity( &self, input: &CreateEntityInput, ) -> Result<CreateEntityResult, BrainHttpError>

Create an entity in the typed graph.

Source

pub async fn resolve_entity( &self, input: &ResolveEntityInput, ) -> Result<ResolveEntityResult, BrainHttpError>

Resolve a candidate name against the typed graph, optionally creating the entity when nothing matches.

Source

pub async fn traverse_relations( &self, entity_id: &str, input: &TraverseInput, ) -> Result<TraverseResult, BrainHttpError>

Walk the relation graph outward from one entity.

Trait Implementations§

Source§

impl Clone for BrainHttpClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrainHttpClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more