pub enum CalculatorRequest {
Add {
a: f64,
b: f64,
responder: CalculatorAddResponder,
},
Subtract {
a: f64,
b: f64,
responder: CalculatorSubtractResponder,
},
Multiply {
a: f64,
b: f64,
responder: CalculatorMultiplyResponder,
},
Divide {
dividend: f64,
divisor: f64,
responder: CalculatorDivideResponder,
},
Pow {
base: f64,
exponent: f64,
responder: CalculatorPowResponder,
},
}Expand description
A protocol for a simple calculator.
Supports the following operations:
- [
fuchsia.examples.calculator/Calculator.Add] - [
fuchsia.examples.calculator/Calculator.Subtract] - [
fuchsia.examples.calculator/Calculator.Multiply] - [
fuchsia.examples.calculator/Calculator.Divide] - [
fuchsia.examples.calculator/Calculator.Pow]
Variants§
Add
Adds two numbers together and returns their sum.
For example, with a being 4.5 and b being 3.2, the response sum is
7.7.
- request
athe first number to be added. - request
bthe second number to be added.
- response
sumthe sum of a and b.
Subtract
Subtracts two numbers and returns their difference.
For example, with a being 7.7 and b being 3.2, the response
difference is 4.5
- request
athe number to be subracted from. - request
bthe number to subtract.
- response
differencethe difference betweenaandb.
Multiply
Multiplies two numbers and returns their product.
For example, with a being 1.5 and b being 2.0, the response
product is 3.0
- request
athe first number used to calculatorulate theproduct. - request
bthe second number used to calculatorulate theproduct.
- response
productthe result of multiplyingaandb.
Divide
Divides one number by another and return the quotient.
For example with a dividend of 2.0 and a divisor of 4.0, the
response quotient is 0.5.
- request
dividendthe number to divide with. - request
divisorthe number to divide into.
- response
quotientthe result of dividing thedividendinto thedivisor.
Pow
Takes base to the exponent and returns the power.
For example with a base of 3.0 and an exponent of 4.0, the response
power is 81.0.
- request
basethe number to multiply by itself. - request
exponentthe number of times to successively multiplybase.
- response
powerthe result of multiplyingbaseby itselfexponenttimes..
Implementations§
Source§impl CalculatorRequest
impl CalculatorRequest
pub fn into_add(self) -> Option<(f64, f64, CalculatorAddResponder)>
pub fn into_subtract(self) -> Option<(f64, f64, CalculatorSubtractResponder)>
pub fn into_multiply(self) -> Option<(f64, f64, CalculatorMultiplyResponder)>
pub fn into_divide(self) -> Option<(f64, f64, CalculatorDivideResponder)>
pub fn into_pow(self) -> Option<(f64, f64, CalculatorPowResponder)>
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
Name of the method defined in FIDL
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CalculatorRequest
impl !RefUnwindSafe for CalculatorRequest
impl Send for CalculatorRequest
impl Sync for CalculatorRequest
impl Unpin for CalculatorRequest
impl !UnwindSafe for CalculatorRequest
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