pub trait ResourceOracle:
Send
+ Sync
+ 'static {
// Required method
fn resolve(&self, kind: &str, name: &str) -> Result<(), String>;
}Expand description
Answers whether a definition that a config names exists, such as a connector a deployment declares, and why not when it does not.
A Compiler given one through CompileOptions::resources checks each
Reference a host function’s spec declares.
A field holding a literal string the oracle does not resolve is an
UNRESOLVED_REFERENCE Defect, whose message leads with the oracle’s
reason when it gives one. A computed or absent value is not checked.
use dataflow_rs::program::ResourceOracle;
/// The deployment's connectors: `orders` a database, `sessions` a cache.
struct Connectors;
impl ResourceOracle for Connectors {
fn resolve(&self, _kind: &str, name: &str) -> Result<(), String> {
match name {
"orders" => Ok(()),
"sessions" => Err(format!("connector `{name}` is a cache, not a database")),
_ => Err(String::new()),
}
}
}Required Methods§
Sourcefn resolve(&self, kind: &str, name: &str) -> Result<(), String>
fn resolve(&self, kind: &str, name: &str) -> Result<(), String>
Ok when a kind named name exists: the connector db1, say.
Err(why) when it does not. A why that is not empty is the issue’s
message, after what did not resolve: `sessions` does not resolve as a connector: connector `sessions` is a cache, not a database.
An empty one gives the plain message: no connector named `db2` resolves.
§Errors
Why name does not resolve, or nothing more to say: an empty string.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".