1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45//! Fuchsia-specific extensions to the FIDL codec.
67mod channel;
8mod handle;
910use zx::Handle;
1112use crate::decoder::InternalHandleDecoder;
13use crate::encoder::InternalHandleEncoder;
14use crate::{DecodeError, EncodeError};
1516pub use self::channel::*;
17pub use self::handle::*;
18pub use zx;
1920/// A decoder which support Zircon handles.
21pub trait HandleDecoder: InternalHandleDecoder {
22/// Takes the next handle from the decoder.
23fn take_handle(&mut self) -> Result<Handle, DecodeError>;
2425/// Returns the number of handles remaining in the decoder.
26fn handles_remaining(&mut self) -> usize;
2728/// Takes the next raw driver handle from the decoder.
29#[doc(hidden)]
30fn take_raw_driver_handle(&mut self) -> Result<u32, DecodeError> {
31Err(DecodeError::DriverHandlesUnsupported)
32 }
33}
3435/// An encoder which supports Zircon handles.
36pub trait HandleEncoder: InternalHandleEncoder {
37/// Pushes a handle into the encoder.
38fn push_handle(&mut self, handle: Handle) -> Result<(), EncodeError>;
3940/// Returns the number of handles added to the encoder.
41fn handles_pushed(&self) -> usize;
4243/// Pushes a raw driver handle into the encoder.
44#[doc(hidden)]
45fn push_raw_driver_handle(&mut self, _raw_driver_handle: u32) -> Result<(), EncodeError> {
46Err(EncodeError::DriverHandlesUnsupported)
47 }
48}