pub struct ExternalLibrary { /* private fields */ }Expand description
A loaded external-function library plus its registered functions.
Implementations§
Source§impl ExternalLibrary
impl ExternalLibrary
Sourcepub fn load(path: &Path) -> Result<Self, String>
pub fn load(path: &Path) -> Result<Self, String>
Open a shared library at path and invoke its funcadd_ASL entry
point, collecting all functions it registers.
Sourcepub fn function_names(&self) -> impl Iterator<Item = &str>
pub fn function_names(&self) -> impl Iterator<Item = &str>
Names of all functions registered by this library.
Sourcepub fn get(&self, name: &str) -> Option<&RegisteredFunc>
pub fn get(&self, name: &str) -> Option<&RegisteredFunc>
Look up a registered function by name.
Sourcepub fn eval(
&self,
name: &str,
args: &[ExternalArg<'_>],
want_derivs: bool,
want_hes: bool,
) -> Result<EvalResult, String>
pub fn eval( &self, name: &str, args: &[ExternalArg<'_>], want_derivs: bool, want_hes: bool, ) -> Result<EvalResult, String>
Evaluate a registered function with the given positional arguments.
Arguments are encoded per the AMPL arglist ABI: real args are stored
in ra[], string args in sa[], and at[i] maps argument position
i to either a real-slot index (at[i] >= 0) or a string-slot index
(at[i] < 0, decoded as -(at[i]+1)).
If want_derivs is set, a length-nr derivative buffer is allocated
and returned on success. If want_hes is set, a length-nr*(nr+1)/2
Hessian buffer is also allocated and returned. The library is told to
fill both by the non-null arglist.derivs / arglist.hes pointers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExternalLibrary
impl RefUnwindSafe for ExternalLibrary
impl Send for ExternalLibrary
impl Sync for ExternalLibrary
impl Unpin for ExternalLibrary
impl UnsafeUnpin for ExternalLibrary
impl UnwindSafe for ExternalLibrary
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more