dhcp_protocol/size_of_contents.rs
1// Copyright 2023 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 std::ops::Deref;
6
7pub(crate) trait SizeOfContents {
8 fn size_of_contents_in_bytes(&self) -> usize;
9}
10
11impl<T, U> SizeOfContents for T
12where
13 T: Deref<Target = [U]>,
14{
15 fn size_of_contents_in_bytes(&self) -> usize {
16 self.deref().len() * std::mem::size_of::<U>()
17 }
18}