pub struct Parameter {
pub name: String,
pub kind: ParamType,
pub required: bool,
pub default: Option<String>,
pub summary: Option<String>,
}Expand description
One declared parameter of a SPARQL script.
Fields§
§name: StringThe variable it binds, and the argument a run passes it as.
kind: ParamTypeWhat its value is.
required: boolWhether a run must pass it.
default: Option<String>The value an absent argument takes, in its lexical form.
summary: Option<String>What it means, for the catalog.
Implementations§
Source§impl Parameter
impl Parameter
Sourcepub fn value(&self, lexical: &str) -> Result<Value>
pub fn value(&self, lexical: &str) -> Result<Value>
Check lexical against this parameter’s type and make it a term: a typed literal
in its canonical form, or an IRI. Refused with InvalidArgument naming the
parameter when it is not one.
use ikigai_script::sparql::{ParamType, Parameter, Value};
let days = Parameter {
name: "days".into(),
kind: ParamType::Datatype("http://www.w3.org/2001/XMLSchema#integer".into()),
required: true,
default: None,
summary: None,
};
match days.value("007").unwrap() {
Value::Literal(l) => assert_eq!(l.to_string(), "\"7\"^^<http://www.w3.org/2001/XMLSchema#integer>"),
other => panic!("{other:?}"),
}
assert!(days.value("seven").is_err());
// Whatever a string parameter holds, it is ONE literal: the serializer escapes it.
let text = Parameter { kind: ParamType::Datatype("http://www.w3.org/2001/XMLSchema#string".into()), ..days };
match text.value("\" } ; DROP ALL ; #").unwrap() {
Value::Literal(l) => assert_eq!(l.value(), "\" } ; DROP ALL ; #"),
other => panic!("{other:?}"),
}Trait Implementations§
Source§impl<'de> Deserialize<'de> for Parameter
impl<'de> Deserialize<'de> for Parameter
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Parameter
impl StructuralPartialEq for Parameter
Auto Trait Implementations§
impl Freeze for Parameter
impl RefUnwindSafe for Parameter
impl Send for Parameter
impl Sync for Parameter
impl Unpin for Parameter
impl UnsafeUnpin for Parameter
impl UnwindSafe for Parameter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more