pub struct HostFunction { /* private fields */ }Expand description
A function implemented by the application.
Implementations§
Source§impl HostFunction
impl HostFunction
Sourcepub fn new(
iri: impl Into<String>,
f: impl Fn(&[Term]) -> Option<Term> + Send + Sync + 'static,
) -> Self
pub fn new( iri: impl Into<String>, f: impl Fn(&[Term]) -> Option<Term> + Send + Sync + 'static, ) -> Self
A function named by iri (checked when it is registered).
Sourcepub fn cypher_name(self, name: impl Into<String>) -> Self
pub fn cypher_name(self, name: impl Into<String>) -> Self
The name Cypher calls it by (default: the local name of the IRI).
Sourcepub fn arity(self, min: usize, max: impl Into<Option<usize>>) -> Self
pub fn arity(self, min: usize, max: impl Into<Option<usize>>) -> Self
How many arguments it takes; a call with another number is an evaluation error.
Sourcepub fn description(self, text: impl Into<String>) -> Self
pub fn description(self, text: impl Into<String>) -> Self
A one-line description, shown by tools (completion, .functions).
pub fn iri(&self) -> &str
Sourcepub fn cypher(&self) -> &str
pub fn cypher(&self) -> &str
The name Cypher calls it by: the explicit one, else the IRI’s local name.
pub fn min_arity(&self) -> usize
pub fn max_arity(&self) -> Option<usize>
pub fn description_text(&self) -> &str
Trait Implementations§
Source§impl Clone for HostFunction
impl Clone for HostFunction
Auto Trait Implementations§
impl !RefUnwindSafe for HostFunction
impl !UnwindSafe for HostFunction
impl Freeze for HostFunction
impl Send for HostFunction
impl Sync for HostFunction
impl Unpin for HostFunction
impl UnsafeUnpin for HostFunction
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