Struct CallableMetadataBuilder

Source
pub struct CallableMetadataBuilder { /* private fields */ }
Expand description

Builder pattern for a callable’s metadata.

Implementations§

Source§

impl CallableMetadataBuilder

Source

pub fn new(name: &'static str) -> Self

Constructs a new metadata builder with the minimum information necessary.

All code except tests must populate the whole builder with details. This is enforced at construction time, where we only allow some fields to be missing under the test configuration.

Source

pub fn new_dynamic(name: String) -> Self

Constructs a new metadata builder with the minimum information necessary.

This is the same as new but using a dynamically-allocated name, which is necessary for user-defined symbols.

Source

pub fn with_return_type(self, return_type: ExprType) -> Self

Sets the return type of the callable.

Source

pub fn with_syntax( self, syntaxes: &'static [(&'static [SingularArgSyntax], Option<&'static RepeatedSyntax>)], ) -> Self

Sets the syntax specifications for this callable.

Source

pub fn with_dynamic_syntax( self, syntaxes: Vec<(Vec<SingularArgSyntax>, Option<RepeatedSyntax>)>, ) -> Self

Sets the syntax specifications for this callable.

Source

pub fn with_category(self, category: &'static str) -> Self

Sets the category for this callable. All callables with the same category name will be grouped together in help messages.

Source

pub fn with_description(self, description: &'static str) -> Self

Sets the description for this callable. The description is a collection of paragraphs separated by a single newline character, where the first paragraph is taken as the summary of the description. The summary must be a short sentence that is descriptive enough to be understood without further details. Empty lines (paragraphs) are not allowed.

Source

pub fn build(self) -> CallableMetadata

Generates the final CallableMetadata object, ensuring all values are present.

Source

pub fn test_build(self) -> CallableMetadata

Generates the final CallableMetadata object, ensuring the minimal set of values are present. Only useful for testing.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.