Struct oso::ClassBuilder
source · [−]pub struct ClassBuilder<T> { /* private fields */ }
Implementations
sourceimpl<T> ClassBuilder<T> where
T: 'static,
impl<T> ClassBuilder<T> where
T: 'static,
sourcepub fn with_default() -> Self where
T: Default,
T: Send + Sync,
pub fn with_default() -> Self where
T: Default,
T: Send + Sync,
Create a new class builder for a type that implements Default and use that as the constructor.
sourcepub fn with_constructor<F, Args>(f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
pub fn with_constructor<F, Args>(f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
Create a new class builder with a given constructor.
sourcepub fn set_constructor<F, Args>(self, f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
pub fn set_constructor<F, Args>(self, f: F) -> Self where
F: Function<Args, Result = T>,
T: Send + Sync,
Args: FromPolarList,
Set the constructor function to use for polar new
statements.
sourcepub fn set_equality_check<F>(self, f: F) -> Self where
F: Fn(&T, &T) -> bool + Send + Sync + 'static,
pub fn set_equality_check<F>(self, f: F) -> Self where
F: Fn(&T, &T) -> bool + Send + Sync + 'static,
Set an equality function to be used for polar ==
statements.
sourcepub fn set_into_iter<F, I, V>(self, f: F) -> Self where
F: Fn(&T) -> I + Send + Sync + 'static,
I: Iterator<Item = V> + Clone + Send + Sync + 'static,
V: ToPolarResult,
pub fn set_into_iter<F, I, V>(self, f: F) -> Self where
F: Fn(&T) -> I + Send + Sync + 'static,
I: Iterator<Item = V> + Clone + Send + Sync + 'static,
V: ToPolarResult,
Set a method to convert instances into iterators
sourcepub fn with_iter<V>(self) -> Self where
T: IntoIterator<Item = V> + Clone,
<T as IntoIterator>::IntoIter: Clone + Send + Sync + 'static,
V: ToPolarResult,
pub fn with_iter<V>(self) -> Self where
T: IntoIterator<Item = V> + Clone,
<T as IntoIterator>::IntoIter: Clone + Send + Sync + 'static,
V: ToPolarResult,
Use the existing IntoIterator
implementation to convert instances into iterators
sourcepub fn with_equality_check(self) -> Self where
T: PartialEq<T>,
pub fn with_equality_check(self) -> Self where
T: PartialEq<T>,
Use PartialEq::eq as the equality check for polar ==
statements.
sourcepub fn add_attribute_getter<F, R>(self, name: &'static str, f: F) -> Self where
F: Fn(&T) -> R + Send + Sync + 'static,
R: ToPolar,
T: 'static,
pub fn add_attribute_getter<F, R>(self, name: &'static str, f: F) -> Self where
F: Fn(&T) -> R + Send + Sync + 'static,
R: ToPolar,
T: 'static,
Add an attribute getter for statements like foo.bar
`class.add_attribute_getter(“bar”, |instance| instance.bar)
sourcepub fn add_constant<V: ToPolar + Clone + Send + Sync + 'static>(
self,
value: V,
name: &'static str
) -> Self
pub fn add_constant<V: ToPolar + Clone + Send + Sync + 'static>(
self,
value: V,
name: &'static str
) -> Self
Add a RegisterHook on the class that will register the given constant once the class is registered.
sourcepub fn add_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args, Result = R>,
R: ToPolarResult + 'static,
pub fn add_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args, Result = R>,
R: ToPolarResult + 'static,
Add a method for polar method calls like foo.plus(1)
class.add_attribute_getter(“bar”, |instance, n| instance.foo + n)
sourcepub fn add_iterator_method<F, Args, I>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args>,
F::Result: IntoIterator<Item = I>,
I: ToPolarResult + 'static,
<<F as Method<T, Args>>::Result as IntoIterator>::IntoIter: Iterator<Item = I> + Clone + Send + Sync + 'static,
T: 'static,
pub fn add_iterator_method<F, Args, I>(self, name: &'static str, f: F) -> Self where
Args: FromPolarList,
F: Method<T, Args>,
F::Result: IntoIterator<Item = I>,
I: ToPolarResult + 'static,
<<F as Method<T, Args>>::Result as IntoIterator>::IntoIter: Iterator<Item = I> + Clone + Send + Sync + 'static,
T: 'static,
A method that returns multiple values. Every element in the iterator returned by the method will be a separate polar return value.
sourcepub fn add_class_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
F: Function<Args, Result = R>,
Args: FromPolarList,
R: ToPolarResult + 'static,
pub fn add_class_method<F, Args, R>(self, name: &'static str, f: F) -> Self where
F: Function<Args, Result = R>,
Args: FromPolarList,
R: ToPolarResult + 'static,
A method that’s called on the type instead of an instance.
eg Foo.pi
Trait Implementations
sourceimpl<T: Clone> Clone for ClassBuilder<T>
impl<T: Clone> Clone for ClassBuilder<T>
sourcefn clone(&self) -> ClassBuilder<T>
fn clone(&self) -> ClassBuilder<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for ClassBuilder<T>
impl<T> Send for ClassBuilder<T> where
T: Send,
impl<T> Sync for ClassBuilder<T> where
T: Sync,
impl<T> Unpin for ClassBuilder<T> where
T: Unpin,
impl<T> !UnwindSafe for ClassBuilder<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more