pub struct CallableMetadataBuilder { /* private fields */ }
Expand description
Builder pattern for a callable’s metadata.
Implementations§
Source§impl CallableMetadataBuilder
impl CallableMetadataBuilder
Sourcepub fn new(name: &'static str) -> Self
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.
Sourcepub fn new_dynamic(name: String) -> Self
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.
Sourcepub fn with_return_type(self, return_type: ExprType) -> Self
pub fn with_return_type(self, return_type: ExprType) -> Self
Sets the return type of the callable.
Sourcepub fn with_syntax(
self,
syntaxes: &'static [(&'static [SingularArgSyntax], Option<&'static RepeatedSyntax>)],
) -> Self
pub fn with_syntax( self, syntaxes: &'static [(&'static [SingularArgSyntax], Option<&'static RepeatedSyntax>)], ) -> Self
Sets the syntax specifications for this callable.
Sourcepub fn with_dynamic_syntax(
self,
syntaxes: Vec<(Vec<SingularArgSyntax>, Option<RepeatedSyntax>)>,
) -> Self
pub fn with_dynamic_syntax( self, syntaxes: Vec<(Vec<SingularArgSyntax>, Option<RepeatedSyntax>)>, ) -> Self
Sets the syntax specifications for this callable.
Sourcepub fn with_category(self, category: &'static str) -> Self
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.
Sourcepub fn with_description(self, description: &'static str) -> Self
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.
Sourcepub fn build(self) -> CallableMetadata
pub fn build(self) -> CallableMetadata
Generates the final CallableMetadata
object, ensuring all values are present.
Sourcepub fn test_build(self) -> CallableMetadata
pub fn test_build(self) -> CallableMetadata
Generates the final CallableMetadata
object, ensuring the minimal set of values are
present. Only useful for testing.