// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /// A trait to determine if the value is left unspecified, /// usually containing the default value. /// /// See: pub trait Unspecified: Sized { /// Returns true if the value is unspecified fn is_unspecified(&self) -> bool; /// Coerce a potentially unspecified value into an Option fn filter_unspecified(self) -> Option { if self.is_unspecified() { None } else { Some(self) } } } macro_rules! unspecified_integer { ($name:ident) => { impl Unspecified for s2n_codec::zerocopy::$name { fn is_unspecified(&self) -> bool { Self::default().eq(self) } } }; } unspecified_integer!(U16); unspecified_integer!(U32); unspecified_integer!(U64); unspecified_integer!(U128);