#![warn(clippy::all)]
#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
#[derive(Clone, Debug)]
pub struct CalculatorAddRequest {
pub a: i32,
pub b: i32,
}
impl ::fidl_next::Encodable for CalculatorAddRequest {
type Encoded<'buf> = WireCalculatorAddRequest;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorAddRequest
where
i32: ::fidl_next::Encode<___E>,
i32: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let Self::Encoded {
a,
b,
} = slot;
}
::fidl_next::Encode::encode(&mut self.a, encoder, a)?;
::fidl_next::Encode::encode(&mut self.b, encoder, b)?;
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorAddRequest> {
type EncodedOption<'buf> = ::fidl_next::WireBox<'buf, WireCalculatorAddRequest>;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorAddRequest>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorAddRequest: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner)?;
::fidl_next::WireBox::encode_present(slot);
} else {
::fidl_next::WireBox::encode_absent(slot);
}
Ok(())
}
}
impl ::fidl_next::TakeFrom<WireCalculatorAddRequest> for CalculatorAddRequest {
fn take_from(from: &mut WireCalculatorAddRequest) -> Self {
Self {
a: ::fidl_next::TakeFrom::take_from(&mut from.a),
b: ::fidl_next::TakeFrom::take_from(&mut from.b),
}
}
}
#[derive(Clone, Debug)]
#[repr(C)]
pub struct WireCalculatorAddRequest {
pub a: ::fidl_next::i32_le,
pub b: ::fidl_next::i32_le,
}
unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddRequest
where
___D: ?Sized,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut a,
mut b,
} = slot;
}
::fidl_next::Decode::decode(a.as_mut(), decoder)?;
::fidl_next::Decode::decode(b.as_mut(), decoder)?;
Ok(())
}
}
#[derive(Clone, Debug)]
pub struct CalculatorAddResponse {
pub sum: i32,
}
impl ::fidl_next::Encodable for CalculatorAddResponse {
type Encoded<'buf> = WireCalculatorAddResponse;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorAddResponse
where
i32: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let Self::Encoded {
sum,
} = slot;
}
::fidl_next::Encode::encode(&mut self.sum, encoder, sum)?;
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorAddResponse> {
type EncodedOption<'buf> = ::fidl_next::WireBox<'buf, WireCalculatorAddResponse>;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorAddResponse>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorAddResponse: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner)?;
::fidl_next::WireBox::encode_present(slot);
} else {
::fidl_next::WireBox::encode_absent(slot);
}
Ok(())
}
}
impl ::fidl_next::TakeFrom<WireCalculatorAddResponse> for CalculatorAddResponse {
fn take_from(from: &mut WireCalculatorAddResponse) -> Self {
Self { sum: ::fidl_next::TakeFrom::take_from(&mut from.sum) }
}
}
#[derive(Clone, Debug)]
#[repr(C)]
pub struct WireCalculatorAddResponse {
pub sum: ::fidl_next::i32_le,
}
unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddResponse
where
___D: ?Sized,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut sum,
} = slot;
}
::fidl_next::Decode::decode(sum.as_mut(), decoder)?;
Ok(())
}
}
#[derive(Clone, Debug)]
pub enum CalculatorAddResult {
Response(crate::CalculatorAddResponse),
FrameworkErr(::fidl_next::FrameworkError),
}
impl ::fidl_next::Encodable for CalculatorAddResult {
type Encoded<'buf> = WireCalculatorAddResult;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorAddResult
where
___E: ::fidl_next::Encoder + ?Sized,
crate::CalculatorAddResponse: ::fidl_next::Encode<___E>,
::fidl_next::FrameworkError: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let WireCalculatorAddResult { raw, _phantom: _ } = slot);
match self {
Self::Response(value) => ::fidl_next::RawWireUnion::encode_as::<
___E,
crate::CalculatorAddResponse,
>(value, 1, encoder, raw)?,
Self::FrameworkErr(value) => ::fidl_next::RawWireUnion::encode_as::<
___E,
::fidl_next::FrameworkError,
>(value, 3, encoder, raw)?,
}
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorAddResult> {
type EncodedOption<'buf> = WireOptionalCalculatorAddResult;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorAddResult>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorAddResult: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
mut slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let WireOptionalCalculatorAddResult { raw, _phantom: _ } = slot.as_mut());
if let Some(inner) = this {
let slot = unsafe { ::fidl_next::Slot::new_unchecked(slot.as_mut_ptr().cast()) };
::fidl_next::Encode::encode(&mut **inner, encoder, slot)?;
} else {
::fidl_next::RawWireUnion::encode_absent(raw);
}
Ok(())
}
}
impl ::fidl_next::TakeFrom<WireCalculatorAddResult> for CalculatorAddResult {
fn take_from(from: &mut WireCalculatorAddResult) -> Self {
match from.raw.ordinal() {
1 => Self::Response(::fidl_next::TakeFrom::take_from(unsafe {
from.raw.get_mut().deref_mut_unchecked()
})),
3 => Self::FrameworkErr(::fidl_next::TakeFrom::take_from(unsafe {
from.raw.get_mut().deref_mut_unchecked()
})),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
impl ::fidl_next::TakeFrom<WireOptionalCalculatorAddResult> for Option<Box<CalculatorAddResult>> {
fn take_from(from: &mut WireOptionalCalculatorAddResult) -> Self {
if let Some(inner) = from.as_mut() {
Some(::fidl_next::TakeFrom::take_from(inner))
} else {
None
}
}
}
#[repr(transparent)]
pub struct WireCalculatorAddResult {
raw: ::fidl_next::RawWireUnion,
_phantom: ::core::marker::PhantomData<()>,
}
pub mod calculator_add_result {
pub enum Ref<'union> {
Response(&'union crate::WireCalculatorAddResponse),
FrameworkErr(&'union ::fidl_next::WireFrameworkError),
}
pub enum Mut<'union> {
Response(&'union mut crate::WireCalculatorAddResponse),
FrameworkErr(&'union mut ::fidl_next::WireFrameworkError),
}
}
impl WireCalculatorAddResult {
pub fn as_ref(&self) -> crate::calculator_add_result::Ref<'_> {
match self.raw.ordinal() {
1 => crate::calculator_add_result::Ref::Response(unsafe {
self.raw.get().deref_unchecked()
}),
3 => crate::calculator_add_result::Ref::FrameworkErr(unsafe {
self.raw.get().deref_unchecked()
}),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
pub fn as_mut(&mut self) -> crate::calculator_add_result::Mut<'_> {
match self.raw.ordinal() {
1 => crate::calculator_add_result::Mut::Response(unsafe {
self.raw.get_mut().deref_mut_unchecked()
}),
3 => crate::calculator_add_result::Mut::FrameworkErr(unsafe {
self.raw.get_mut().deref_mut_unchecked()
}),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
impl Clone for WireCalculatorAddResult {
fn clone(&self) -> Self {
match self.raw.ordinal() {
1 => Self {
raw: unsafe { self.raw.clone_unchecked::<crate::WireCalculatorAddResponse>() },
_phantom: ::core::marker::PhantomData,
},
3 => Self {
raw: unsafe { self.raw.clone_unchecked::<::fidl_next::WireFrameworkError>() },
_phantom: ::core::marker::PhantomData,
},
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
unsafe impl<___D: ?Sized> ::fidl_next::Decode<___D> for WireCalculatorAddResult
where
___D: fidl_next::decoder::InternalHandleDecoder,
crate::WireCalculatorAddResponse: ::fidl_next::Decode<___D>,
::fidl_next::WireFrameworkError: ::fidl_next::Decode<___D>,
{
fn decode(
mut slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
1 => ::fidl_next::RawWireUnion::decode_as_static::<
___D,
crate::WireCalculatorAddResponse,
>(raw, decoder)?,
3 => ::fidl_next::RawWireUnion::decode_as_static::<
___D,
::fidl_next::WireFrameworkError,
>(raw, decoder)?,
ord => return Err(::fidl_next::DecodeError::InvalidUnionOrdinal(ord as usize)),
}
Ok(())
}
}
impl ::core::fmt::Debug for WireCalculatorAddResult {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
match self.raw.ordinal() {
1 => unsafe {
self.raw.get().deref_unchecked::<crate::WireCalculatorAddResponse>().fmt(f)
},
3 => unsafe {
self.raw.get().deref_unchecked::<::fidl_next::WireFrameworkError>().fmt(f)
},
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
#[repr(transparent)]
pub struct WireOptionalCalculatorAddResult {
raw: ::fidl_next::RawWireUnion,
_phantom: ::core::marker::PhantomData<()>,
}
impl WireOptionalCalculatorAddResult {
pub fn is_some(&self) -> bool {
self.raw.is_some()
}
pub fn is_none(&self) -> bool {
self.raw.is_none()
}
pub fn as_ref(&self) -> Option<&WireCalculatorAddResult> {
if self.is_some() {
Some(unsafe { &*(self as *const Self).cast() })
} else {
None
}
}
pub fn as_mut(&mut self) -> Option<&mut WireCalculatorAddResult> {
if self.is_some() {
Some(unsafe { &mut *(self as *mut Self).cast() })
} else {
None
}
}
pub fn take(&mut self) -> Option<WireCalculatorAddResult> {
if self.is_some() {
Some(WireCalculatorAddResult {
raw: ::core::mem::replace(&mut self.raw, ::fidl_next::RawWireUnion::null()),
_phantom: ::core::marker::PhantomData,
})
} else {
None
}
}
}
impl Default for WireOptionalCalculatorAddResult {
fn default() -> Self {
Self { raw: ::fidl_next::RawWireUnion::null(), _phantom: ::core::marker::PhantomData }
}
}
impl Clone for WireOptionalCalculatorAddResult {
fn clone(&self) -> Self {
if self.is_none() {
return WireOptionalCalculatorAddResult {
raw: ::fidl_next::RawWireUnion::null(),
_phantom: ::core::marker::PhantomData,
};
}
match self.raw.ordinal() {
1 => Self {
raw: unsafe { self.raw.clone_unchecked::<crate::WireCalculatorAddResponse>() },
_phantom: ::core::marker::PhantomData,
},
3 => Self {
raw: unsafe { self.raw.clone_unchecked::<::fidl_next::WireFrameworkError>() },
_phantom: ::core::marker::PhantomData,
},
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
unsafe impl<___D: ?Sized> ::fidl_next::Decode<___D> for WireOptionalCalculatorAddResult
where
___D: fidl_next::decoder::InternalHandleDecoder,
crate::WireCalculatorAddResponse: ::fidl_next::Decode<___D>,
::fidl_next::WireFrameworkError: ::fidl_next::Decode<___D>,
{
fn decode(
mut slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
1 => ::fidl_next::RawWireUnion::decode_as_static::<
___D,
crate::WireCalculatorAddResponse,
>(raw, decoder)?,
3 => ::fidl_next::RawWireUnion::decode_as_static::<
___D,
::fidl_next::WireFrameworkError,
>(raw, decoder)?,
0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
_ => ::fidl_next::RawWireUnion::decode_unknown_static(raw, decoder)?,
}
Ok(())
}
}
impl ::core::fmt::Debug for WireOptionalCalculatorAddResult {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
self.as_ref().fmt(f)
}
}
#[derive(Clone, Debug)]
pub struct CalculatorDivideRequest {
pub dividend: i32,
pub divisor: i32,
}
impl ::fidl_next::Encodable for CalculatorDivideRequest {
type Encoded<'buf> = WireCalculatorDivideRequest;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideRequest
where
i32: ::fidl_next::Encode<___E>,
i32: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let Self::Encoded {
dividend,
divisor,
} = slot;
}
::fidl_next::Encode::encode(&mut self.dividend, encoder, dividend)?;
::fidl_next::Encode::encode(&mut self.divisor, encoder, divisor)?;
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorDivideRequest> {
type EncodedOption<'buf> = ::fidl_next::WireBox<'buf, WireCalculatorDivideRequest>;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideRequest>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorDivideRequest: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner)?;
::fidl_next::WireBox::encode_present(slot);
} else {
::fidl_next::WireBox::encode_absent(slot);
}
Ok(())
}
}
impl ::fidl_next::TakeFrom<WireCalculatorDivideRequest> for CalculatorDivideRequest {
fn take_from(from: &mut WireCalculatorDivideRequest) -> Self {
Self {
dividend: ::fidl_next::TakeFrom::take_from(&mut from.dividend),
divisor: ::fidl_next::TakeFrom::take_from(&mut from.divisor),
}
}
}
#[derive(Clone, Debug)]
#[repr(C)]
pub struct WireCalculatorDivideRequest {
pub dividend: ::fidl_next::i32_le,
pub divisor: ::fidl_next::i32_le,
}
unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideRequest
where
___D: ?Sized,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut dividend,
mut divisor,
} = slot;
}
::fidl_next::Decode::decode(dividend.as_mut(), decoder)?;
::fidl_next::Decode::decode(divisor.as_mut(), decoder)?;
Ok(())
}
}
#[derive(Clone, Debug)]
pub struct CalculatorDivideResponse {
pub quotient: i32,
pub remainder: i32,
}
impl ::fidl_next::Encodable for CalculatorDivideResponse {
type Encoded<'buf> = WireCalculatorDivideResponse;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideResponse
where
i32: ::fidl_next::Encode<___E>,
i32: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let Self::Encoded {
quotient,
remainder,
} = slot;
}
::fidl_next::Encode::encode(&mut self.quotient, encoder, quotient)?;
::fidl_next::Encode::encode(&mut self.remainder, encoder, remainder)?;
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorDivideResponse> {
type EncodedOption<'buf> = ::fidl_next::WireBox<'buf, WireCalculatorDivideResponse>;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideResponse>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorDivideResponse: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner)?;
::fidl_next::WireBox::encode_present(slot);
} else {
::fidl_next::WireBox::encode_absent(slot);
}
Ok(())
}
}
impl ::fidl_next::TakeFrom<WireCalculatorDivideResponse> for CalculatorDivideResponse {
fn take_from(from: &mut WireCalculatorDivideResponse) -> Self {
Self {
quotient: ::fidl_next::TakeFrom::take_from(&mut from.quotient),
remainder: ::fidl_next::TakeFrom::take_from(&mut from.remainder),
}
}
}
#[derive(Clone, Debug)]
#[repr(C)]
pub struct WireCalculatorDivideResponse {
pub quotient: ::fidl_next::i32_le,
pub remainder: ::fidl_next::i32_le,
}
unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideResponse
where
___D: ?Sized,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
::fidl_next::i32_le: ::fidl_next::Decode<___D>,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut quotient,
mut remainder,
} = slot;
}
::fidl_next::Decode::decode(quotient.as_mut(), decoder)?;
::fidl_next::Decode::decode(remainder.as_mut(), decoder)?;
Ok(())
}
}
#[derive(Clone, Copy, Debug)]
#[repr(u32)]
pub enum DivisionError {
DivideByZero = 1,
}
impl ::fidl_next::Encodable for DivisionError {
type Encoded<'buf> = WireDivisionError;
}
impl<___E> ::fidl_next::Encode<___E> for DivisionError
where
___E: ?Sized,
{
fn encode(
&mut self,
_: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let WireDivisionError { mut value } = slot);
*value = ::fidl_next::u32_le::from(match *self {
Self::DivideByZero => 1,
});
Ok(())
}
}
impl ::core::convert::From<WireDivisionError> for DivisionError {
fn from(wire: WireDivisionError) -> Self {
match u32::from(wire.value) {
1 => Self::DivideByZero,
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
impl ::fidl_next::TakeFrom<WireDivisionError> for DivisionError {
fn take_from(from: &mut WireDivisionError) -> Self {
Self::from(*from)
}
}
#[derive(Clone, Copy, Debug)]
#[repr(transparent)]
pub struct WireDivisionError {
value: ::fidl_next::u32_le,
}
impl WireDivisionError {
pub const DIVIDE_BY_ZERO: WireDivisionError =
WireDivisionError { value: ::fidl_next::u32_le::from_native(1) };
}
unsafe impl<___D> ::fidl_next::Decode<___D> for WireDivisionError
where
___D: ?Sized,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
_: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { value } = slot);
match u32::from(*value) {
1 => (),
unknown => return Err(::fidl_next::DecodeError::InvalidEnumOrdinal(unknown as i128)),
}
Ok(())
}
}
impl ::core::convert::From<DivisionError> for WireDivisionError {
fn from(natural: DivisionError) -> Self {
match natural {
DivisionError::DivideByZero => WireDivisionError::DIVIDE_BY_ZERO,
}
}
}
#[derive(Clone, Debug)]
pub enum CalculatorDivideResult {
Response(crate::CalculatorDivideResponse),
Err(crate::DivisionError),
FrameworkErr(::fidl_next::FrameworkError),
}
impl ::fidl_next::Encodable for CalculatorDivideResult {
type Encoded<'buf> = WireCalculatorDivideResult<'buf>;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideResult
where
___E: ::fidl_next::Encoder + ?Sized,
crate::CalculatorDivideResponse: ::fidl_next::Encode<___E>,
crate::DivisionError: ::fidl_next::Encode<___E>,
::fidl_next::FrameworkError: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let WireCalculatorDivideResult { raw, _phantom: _ } = slot);
match self {
Self::Response(value) => ::fidl_next::RawWireUnion::encode_as::<
___E,
crate::CalculatorDivideResponse,
>(value, 1, encoder, raw)?,
Self::Err(value) => ::fidl_next::RawWireUnion::encode_as::<___E, crate::DivisionError>(
value, 2, encoder, raw,
)?,
Self::FrameworkErr(value) => ::fidl_next::RawWireUnion::encode_as::<
___E,
::fidl_next::FrameworkError,
>(value, 3, encoder, raw)?,
}
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorDivideResult> {
type EncodedOption<'buf> = WireOptionalCalculatorDivideResult<'buf>;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideResult>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorDivideResult: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
mut slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let WireOptionalCalculatorDivideResult { raw, _phantom: _ } = slot.as_mut());
if let Some(inner) = this {
let slot = unsafe { ::fidl_next::Slot::new_unchecked(slot.as_mut_ptr().cast()) };
::fidl_next::Encode::encode(&mut **inner, encoder, slot)?;
} else {
::fidl_next::RawWireUnion::encode_absent(raw);
}
Ok(())
}
}
impl<'buf> ::fidl_next::TakeFrom<WireCalculatorDivideResult<'buf>> for CalculatorDivideResult {
fn take_from(from: &mut WireCalculatorDivideResult<'buf>) -> Self {
match from.raw.ordinal() {
1 => Self::Response(::fidl_next::TakeFrom::take_from(unsafe {
from.raw.get_mut().deref_mut_unchecked()
})),
2 => Self::Err(::fidl_next::TakeFrom::take_from(unsafe {
from.raw.get_mut().deref_mut_unchecked()
})),
3 => Self::FrameworkErr(::fidl_next::TakeFrom::take_from(unsafe {
from.raw.get_mut().deref_mut_unchecked()
})),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
impl<'buf> ::fidl_next::TakeFrom<WireOptionalCalculatorDivideResult<'buf>>
for Option<Box<CalculatorDivideResult>>
{
fn take_from(from: &mut WireOptionalCalculatorDivideResult<'buf>) -> Self {
if let Some(inner) = from.as_mut() {
Some(::fidl_next::TakeFrom::take_from(inner))
} else {
None
}
}
}
#[repr(transparent)]
pub struct WireCalculatorDivideResult<'buf> {
raw: ::fidl_next::RawWireUnion,
_phantom: ::core::marker::PhantomData<&'buf mut [::fidl_next::Chunk]>,
}
pub mod calculator_divide_result {
pub enum Ref<'union> {
Response(&'union crate::WireCalculatorDivideResponse),
Err(&'union crate::WireDivisionError),
FrameworkErr(&'union ::fidl_next::WireFrameworkError),
}
pub enum Mut<'union> {
Response(&'union mut crate::WireCalculatorDivideResponse),
Err(&'union mut crate::WireDivisionError),
FrameworkErr(&'union mut ::fidl_next::WireFrameworkError),
}
}
impl<'buf> WireCalculatorDivideResult<'buf> {
pub fn as_ref(&self) -> crate::calculator_divide_result::Ref<'_> {
match self.raw.ordinal() {
1 => crate::calculator_divide_result::Ref::Response(unsafe {
self.raw.get().deref_unchecked()
}),
2 => crate::calculator_divide_result::Ref::Err(unsafe {
self.raw.get().deref_unchecked()
}),
3 => crate::calculator_divide_result::Ref::FrameworkErr(unsafe {
self.raw.get().deref_unchecked()
}),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
pub fn as_mut(&mut self) -> crate::calculator_divide_result::Mut<'_> {
match self.raw.ordinal() {
1 => crate::calculator_divide_result::Mut::Response(unsafe {
self.raw.get_mut().deref_mut_unchecked()
}),
2 => crate::calculator_divide_result::Mut::Err(unsafe {
self.raw.get_mut().deref_mut_unchecked()
}),
3 => crate::calculator_divide_result::Mut::FrameworkErr(unsafe {
self.raw.get_mut().deref_mut_unchecked()
}),
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
unsafe impl<'buf, ___D: ?Sized> ::fidl_next::Decode<___D> for WireCalculatorDivideResult<'buf>
where
___D: ::fidl_next::Decoder<'buf>,
crate::WireCalculatorDivideResponse: ::fidl_next::Decode<___D>,
crate::WireDivisionError: ::fidl_next::Decode<___D>,
::fidl_next::WireFrameworkError: ::fidl_next::Decode<___D>,
{
fn decode(
mut slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
1 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireCalculatorDivideResponse>(
raw, decoder,
)?,
2 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireDivisionError>(
raw, decoder,
)?,
3 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireFrameworkError>(
raw, decoder,
)?,
ord => return Err(::fidl_next::DecodeError::InvalidUnionOrdinal(ord as usize)),
}
Ok(())
}
}
impl<'buf> ::core::fmt::Debug for WireCalculatorDivideResult<'buf> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
match self.raw.ordinal() {
1 => unsafe {
self.raw.get().deref_unchecked::<crate::WireCalculatorDivideResponse>().fmt(f)
},
2 => unsafe { self.raw.get().deref_unchecked::<crate::WireDivisionError>().fmt(f) },
3 => unsafe {
self.raw.get().deref_unchecked::<::fidl_next::WireFrameworkError>().fmt(f)
},
_ => unsafe { ::core::hint::unreachable_unchecked() },
}
}
}
#[repr(transparent)]
pub struct WireOptionalCalculatorDivideResult<'buf> {
raw: ::fidl_next::RawWireUnion,
_phantom: ::core::marker::PhantomData<&'buf mut [::fidl_next::Chunk]>,
}
impl<'buf> WireOptionalCalculatorDivideResult<'buf> {
pub fn is_some(&self) -> bool {
self.raw.is_some()
}
pub fn is_none(&self) -> bool {
self.raw.is_none()
}
pub fn as_ref(&self) -> Option<&WireCalculatorDivideResult<'buf>> {
if self.is_some() {
Some(unsafe { &*(self as *const Self).cast() })
} else {
None
}
}
pub fn as_mut(&mut self) -> Option<&mut WireCalculatorDivideResult<'buf>> {
if self.is_some() {
Some(unsafe { &mut *(self as *mut Self).cast() })
} else {
None
}
}
pub fn take(&mut self) -> Option<WireCalculatorDivideResult<'buf>> {
if self.is_some() {
Some(WireCalculatorDivideResult {
raw: ::core::mem::replace(&mut self.raw, ::fidl_next::RawWireUnion::null()),
_phantom: ::core::marker::PhantomData,
})
} else {
None
}
}
}
impl<'buf> Default for WireOptionalCalculatorDivideResult<'buf> {
fn default() -> Self {
Self { raw: ::fidl_next::RawWireUnion::null(), _phantom: ::core::marker::PhantomData }
}
}
unsafe impl<'buf, ___D: ?Sized> ::fidl_next::Decode<___D>
for WireOptionalCalculatorDivideResult<'buf>
where
___D: ::fidl_next::Decoder<'buf>,
crate::WireCalculatorDivideResponse: ::fidl_next::Decode<___D>,
crate::WireDivisionError: ::fidl_next::Decode<___D>,
::fidl_next::WireFrameworkError: ::fidl_next::Decode<___D>,
{
fn decode(
mut slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
1 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireCalculatorDivideResponse>(
raw, decoder,
)?,
2 => ::fidl_next::RawWireUnion::decode_as::<___D, crate::WireDivisionError>(
raw, decoder,
)?,
3 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireFrameworkError>(
raw, decoder,
)?,
0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
_ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
}
Ok(())
}
}
impl<'buf> ::core::fmt::Debug for WireOptionalCalculatorDivideResult<'buf> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
self.as_ref().fmt(f)
}
}
#[derive(Clone, Debug)]
pub struct CalculatorOnErrorRequest {
pub status_code: u32,
}
impl ::fidl_next::Encodable for CalculatorOnErrorRequest {
type Encoded<'buf> = WireCalculatorOnErrorRequest;
}
impl<___E> ::fidl_next::Encode<___E> for CalculatorOnErrorRequest
where
u32: ::fidl_next::Encode<___E>,
{
fn encode(
&mut self,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::Encoded<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge! {
let Self::Encoded {
status_code,
} = slot;
}
::fidl_next::Encode::encode(&mut self.status_code, encoder, status_code)?;
Ok(())
}
}
impl ::fidl_next::EncodableOption for Box<CalculatorOnErrorRequest> {
type EncodedOption<'buf> = ::fidl_next::WireBox<'buf, WireCalculatorOnErrorRequest>;
}
impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorOnErrorRequest>
where
___E: ::fidl_next::Encoder + ?Sized,
CalculatorOnErrorRequest: ::fidl_next::Encode<___E>,
{
fn encode_option(
this: Option<&mut Self>,
encoder: &mut ___E,
slot: ::fidl_next::Slot<'_, Self::EncodedOption<'_>>,
) -> Result<(), ::fidl_next::EncodeError> {
if let Some(inner) = this {
::fidl_next::EncoderExt::encode_next(encoder, inner)?;
::fidl_next::WireBox::encode_present(slot);
} else {
::fidl_next::WireBox::encode_absent(slot);
}
Ok(())
}
}
impl ::fidl_next::TakeFrom<WireCalculatorOnErrorRequest> for CalculatorOnErrorRequest {
fn take_from(from: &mut WireCalculatorOnErrorRequest) -> Self {
Self { status_code: ::fidl_next::TakeFrom::take_from(&mut from.status_code) }
}
}
#[derive(Clone, Debug)]
#[repr(C)]
pub struct WireCalculatorOnErrorRequest {
pub status_code: ::fidl_next::u32_le,
}
unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorOnErrorRequest
where
___D: ?Sized,
::fidl_next::u32_le: ::fidl_next::Decode<___D>,
{
fn decode(
slot: ::fidl_next::Slot<'_, Self>,
decoder: &mut ___D,
) -> Result<(), ::fidl_next::DecodeError> {
::fidl_next::munge! {
let Self {
mut status_code,
} = slot;
}
::fidl_next::Decode::decode(status_code.as_mut(), decoder)?;
Ok(())
}
}
#[derive(Debug)]
pub struct Calculator;
pub mod calculator {
pub struct Add;
impl ::fidl_next::bind::Method for Add {
const ORDINAL: u64 = 8640324702111165953;
type Protocol = crate::Calculator;
type Request<'buf> = crate::WireCalculatorAddRequest;
type Response<'buf> = crate::WireCalculatorAddResult;
}
pub struct Divide;
impl ::fidl_next::bind::Method for Divide {
const ORDINAL: u64 = 5497947425807432439;
type Protocol = crate::Calculator;
type Request<'buf> = crate::WireCalculatorDivideRequest;
type Response<'buf> = crate::WireCalculatorDivideResult<'buf>;
}
pub struct Clear;
impl ::fidl_next::bind::Method for Clear {
const ORDINAL: u64 = 7439411180362570889;
type Protocol = crate::Calculator;
type Request<'buf> = ();
type Response<'buf> = ::fidl_next::bind::Never;
}
pub struct OnError;
impl ::fidl_next::bind::Method for OnError {
const ORDINAL: u64 = 8940578522385404924;
type Protocol = crate::Calculator;
type Request<'buf> = ::fidl_next::bind::Never;
type Response<'buf> = crate::WireCalculatorOnErrorRequest;
}
}
pub trait CalculatorClient<___T: ::fidl_next::protocol::Transport> {
fn add<___R>(
&self,
request: &mut ___R,
) -> Result<
::fidl_next::bind::TransactionFuture<'_, ___T, calculator::Add>,
::fidl_next::EncodeError,
>
where
for<'buf> ___R: ::fidl_next::Encode<
___T::Encoder<'buf>,
Encoded<'buf> = crate::WireCalculatorAddRequest,
>;
fn divide<___R>(
&self,
request: &mut ___R,
) -> Result<
::fidl_next::bind::TransactionFuture<'_, ___T, calculator::Divide>,
::fidl_next::EncodeError,
>
where
for<'buf> ___R: ::fidl_next::Encode<
___T::Encoder<'buf>,
Encoded<'buf> = crate::WireCalculatorDivideRequest,
>;
fn clear(&self) -> Result<___T::SendFuture<'_>, ::fidl_next::EncodeError>;
}
impl<___T> CalculatorClient<___T> for ::fidl_next::bind::Client<___T, Calculator>
where
___T: ::fidl_next::protocol::Transport,
{
fn add<___R>(
&self,
request: &mut ___R,
) -> Result<
::fidl_next::bind::TransactionFuture<'_, ___T, calculator::Add>,
::fidl_next::EncodeError,
>
where
for<'buf> ___R: ::fidl_next::Encode<
___T::Encoder<'buf>,
Encoded<'buf> = crate::WireCalculatorAddRequest,
>,
{
self.untyped()
.send_transaction(8640324702111165953, request)
.map(::fidl_next::bind::TransactionFuture::from_untyped)
}
fn divide<___R>(
&self,
request: &mut ___R,
) -> Result<
::fidl_next::bind::TransactionFuture<'_, ___T, calculator::Divide>,
::fidl_next::EncodeError,
>
where
for<'buf> ___R: ::fidl_next::Encode<
___T::Encoder<'buf>,
Encoded<'buf> = crate::WireCalculatorDivideRequest,
>,
{
self.untyped()
.send_transaction(5497947425807432439, request)
.map(::fidl_next::bind::TransactionFuture::from_untyped)
}
fn clear(&self) -> Result<___T::SendFuture<'_>, ::fidl_next::EncodeError> {
self.untyped().send_request(7439411180362570889, &mut ())
}
}
pub trait CalculatorClientHandler<___T: ::fidl_next::protocol::Transport> {
fn on_error(&mut self, message: ::fidl_next::bind::ResponseBuffer<___T, calculator::OnError>);
fn handle_unknown_interaction(&mut self, ordinal: u64);
}
impl<___T, ___H> ::fidl_next::bind::ClientProtocol<___T, ___H> for Calculator
where
___T: ::fidl_next::protocol::Transport,
___H: CalculatorClientHandler<___T>,
for<'buf> crate::WireCalculatorAddResult:
::fidl_next::Decode<<___T as ::fidl_next::protocol::Transport>::Decoder<'buf>>,
for<'buf> crate::WireCalculatorDivideResult<'buf>:
::fidl_next::Decode<<___T as ::fidl_next::protocol::Transport>::Decoder<'buf>>,
for<'buf> crate::WireCalculatorOnErrorRequest:
::fidl_next::Decode<<___T as ::fidl_next::protocol::Transport>::Decoder<'buf>>,
{
fn on_event(handler: &mut ___H, ordinal: u64, buffer: ___T::RecvBuffer) {
match ordinal {
8940578522385404924 => {
let buffer = ::fidl_next::bind::ResponseBuffer::from_untyped(buffer);
handler.on_error(buffer);
}
ordinal => handler.handle_unknown_interaction(ordinal),
}
}
}
pub trait CalculatorServer<___T: ::fidl_next::protocol::Transport> {
fn on_error(&self) -> Result<___T::SendFuture<'_>, ::fidl_next::EncodeError>;
}
impl<___T> CalculatorServer<___T> for ::fidl_next::bind::Server<___T, Calculator>
where
___T: ::fidl_next::protocol::Transport,
{
fn on_error(&self) -> Result<___T::SendFuture<'_>, ::fidl_next::EncodeError> {
self.untyped().send_event(8940578522385404924, &mut ())
}
}
pub trait CalculatorServerHandler<___T: ::fidl_next::protocol::Transport> {
fn add(
&mut self,
request: ::fidl_next::bind::RequestBuffer<___T, calculator::Add>,
responder: ::fidl_next::bind::Responder<calculator::Add>,
);
fn divide(
&mut self,
request: ::fidl_next::bind::RequestBuffer<___T, calculator::Divide>,
responder: ::fidl_next::bind::Responder<calculator::Divide>,
);
fn clear(&mut self);
fn handle_unknown_interaction(&mut self, ordinal: u64);
}
impl<___T, ___H> ::fidl_next::bind::ServerProtocol<___T, ___H> for Calculator
where
___T: ::fidl_next::protocol::Transport,
___H: CalculatorServerHandler<___T>,
for<'buf> crate::WireCalculatorAddRequest:
::fidl_next::Decode<<___T as ::fidl_next::protocol::Transport>::Decoder<'buf>>,
for<'buf> crate::WireCalculatorDivideRequest:
::fidl_next::Decode<<___T as ::fidl_next::protocol::Transport>::Decoder<'buf>>,
{
fn on_event(handler: &mut ___H, ordinal: u64, buffer: ___T::RecvBuffer) {
match ordinal {
7439411180362570889 => {
handler.clear();
}
ordinal => handler.handle_unknown_interaction(ordinal),
}
}
fn on_transaction(
handler: &mut ___H,
ordinal: u64,
mut buffer: ___T::RecvBuffer,
responder: ::fidl_next::protocol::Responder,
) {
match ordinal {
8640324702111165953 => {
let responder = ::fidl_next::bind::Responder::from_untyped(responder);
let buffer = ::fidl_next::bind::RequestBuffer::from_untyped(buffer);
handler.add(buffer, responder);
}
5497947425807432439 => {
let responder = ::fidl_next::bind::Responder::from_untyped(responder);
let buffer = ::fidl_next::bind::RequestBuffer::from_untyped(buffer);
handler.divide(buffer, responder);
}
ordinal => handler.handle_unknown_interaction(ordinal),
}
}
}