Skip to main content

fidl_next_codec/convert/
into.rs

1// Copyright 2025 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.
4
5use crate::FromWire;
6
7/// Associates a good default type for a wire type to convert into.
8pub trait IntoNatural: Sized {
9    /// A good default type for this wire type to convert into.
10    type Natural: FromWire<Self>;
11
12    /// Converts this type into its natural equivalent.
13    fn into_natural(self) -> Self::Natural {
14        Self::Natural::from_wire(self)
15    }
16}
17
18impl<T: IntoNatural, const N: usize> IntoNatural for [T; N] {
19    type Natural = [T::Natural; N];
20}