pub struct Signature {
pub parameters: Vec<Box<dyn DataType>>,
pub return_type: Box<dyn DataType>,
}
Expand description
Signature struct is a representation of function type
Function type in GitQL used to track parameters and return type for now but later can track parameter names to allow pass parameter by name and improve error messages
GitQL Function Signature has some rules to follow
Rules:
- Parameters must contains 0 or 1 [
VarargsType
] parameter type only. - [
VarargsType
] must be the last parameter. - You can add 0 or more [
DataType::Optional
] parameters. - [
OptionalType
] parameters must be at the end but also before [VarargsType
] if exists.
The return type can be a static DataType
such as Int, Float or Dynamic
so you can return a dynamic type depending on parameters.
Fields§
§parameters: Vec<Box<dyn DataType>>
§return_type: Box<dyn DataType>
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn new(
parameters: Vec<Box<dyn DataType>>,
return_type: Box<dyn DataType>,
) -> Self
pub fn new( parameters: Vec<Box<dyn DataType>>, return_type: Box<dyn DataType>, ) -> Self
Create Instance of Signature
with parameters and return type
Sourcepub fn with_return(return_type: Box<dyn DataType>) -> Self
pub fn with_return(return_type: Box<dyn DataType>) -> Self
Create Instance of Signature
with return type and zero parameters
Sourcepub fn add_parameters(self, parameters: Vec<Box<dyn DataType>>) -> Self
pub fn add_parameters(self, parameters: Vec<Box<dyn DataType>>) -> Self
Add list of parameters to the Signature
Sourcepub fn add_parameter(self, parameter: Box<dyn DataType>) -> Self
pub fn add_parameter(self, parameter: Box<dyn DataType>) -> Self
Add parameter to the Signature
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Signature
impl !RefUnwindSafe for Signature
impl !Send for Signature
impl !Sync for Signature
impl Unpin for Signature
impl !UnwindSafe for Signature
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