pub struct Engine { /* private fields */ }Expand description
The sources a configuration resolved to, and the queries they answer.
Implementations§
Source§impl Engine
impl Engine
Sourcepub async fn copy(
&self,
request: &CopyRequest,
) -> Result<CopyReport, EngineError>
pub async fn copy( &self, request: &CopyRequest, ) -> Result<CopyReport, EngineError>
Copy every item a request names into one configured destination.
This is the whole of the verb, and the command line drives exactly this: a copy a Rust caller makes and a copy typed at a shell are the same call, so the two cannot answer the same copy differently.
§Errors
Returns EngineError when the destination is not configured, cannot be built or
cannot be written; when an id names nothing; when an origin names an item the
destination no longer holds and --recreate was not given; and when the
destination refuses the write — including a field or a metadata key it cannot
carry, which it names rather than dropping.
Source§impl Engine
impl Engine
Sourcepub fn build(config: &Config, secrets: &dyn SecretResolver) -> Self
pub fn build(config: &Config, secrets: &dyn SecretResolver) -> Self
Build every source a configuration names.
A source whose plugin refuses to build — a credential that is not there, a
plugin whose implementation has not landed — is not fatal: it becomes an
entry in every response’s errors, exactly as a source that fails mid-query
does, and the other sources still answer. A user with three sources and one
expired token gets the other two rather than nothing.
Sourcepub fn new(sources: Vec<ConfiguredSource>, selection: Vec<SourceName>) -> Self
pub fn new(sources: Vec<ConfiguredSource>, selection: Vec<SourceName>) -> Self
Drive sources built elsewhere — the engine’s own tests, and any caller holding a source it did not resolve from a configuration document.
Sourcepub fn listing(&self) -> Vec<SourceListing>
pub fn listing(&self) -> Vec<SourceListing>
Every configured source, whether or not it built, in name order.
Sourcepub fn has(&self, name: &SourceName) -> bool
pub fn has(&self, name: &SourceName) -> bool
Whether this configuration has a source called name, built or not.
A caller reading a --project argument needs this: urn:project:1 is a qualified
id only if urn is a source here, and a native id full of colons otherwise. That
rule cannot be applied without knowing what is configured.
Sourcepub async fn tasks(
&self,
request: &TaskRequest,
) -> Result<QueryResponse<Qualified<Task>>, EngineError>
pub async fn tasks( &self, request: &TaskRequest, ) -> Result<QueryResponse<Qualified<Task>>, EngineError>
One page of tasks.
§Errors
Returns EngineError when the request names a source nothing configures, or
carries a page token this engine did not issue. One source failing is not an
error: it lands in the response’s errors.
Sourcepub async fn projects(
&self,
request: &ProjectRequest,
) -> Result<QueryResponse<Qualified<Project>>, EngineError>
pub async fn projects( &self, request: &ProjectRequest, ) -> Result<QueryResponse<Qualified<Project>>, EngineError>
Sourcepub async fn labels(
&self,
request: &LabelRequest,
) -> Result<QueryResponse<Qualified<Label>>, EngineError>
pub async fn labels( &self, request: &LabelRequest, ) -> Result<QueryResponse<Qualified<Label>>, EngineError>
Sourcepub async fn search(
&self,
request: &SearchRequest,
) -> Result<QueryResponse<SearchHit>, EngineError>
pub async fn search( &self, request: &SearchRequest, ) -> Result<QueryResponse<SearchHit>, EngineError>
Sourcepub async fn task(
&self,
id: &GlobalId,
) -> Result<QueryResponse<Qualified<Task>>, EngineError>
pub async fn task( &self, id: &GlobalId, ) -> Result<QueryResponse<Qualified<Task>>, EngineError>
One task by its qualified id, or an empty page when there is no such task.
§Errors
Returns EngineError::UnknownSource when the id names a source nothing
configures.
Sourcepub async fn project(
&self,
id: &GlobalId,
) -> Result<QueryResponse<Qualified<Project>>, EngineError>
pub async fn project( &self, id: &GlobalId, ) -> Result<QueryResponse<Qualified<Project>>, EngineError>
Sourcepub async fn task_dependencies(
&self,
request: &DependencyRequest,
) -> Result<QueryResponse<QualifiedEdge>, EngineError>
pub async fn task_dependencies( &self, request: &DependencyRequest, ) -> Result<QueryResponse<QualifiedEdge>, EngineError>
One page of a task’s dependency edges.
§Errors
As task, plus EngineError::Token for a page token this engine
did not issue.