datasize/
futures.rs

1use super::DataSize;
2use core::mem::size_of;
3
4impl<T> DataSize for futures::channel::oneshot::Sender<T> {
5    const IS_DYNAMIC: bool = false;
6    const STATIC_HEAP_SIZE: usize = 0;
7
8    #[inline]
9    fn estimate_heap_size(&self) -> usize {
10        0
11    }
12}
13
14// Note: We attribute the value to be sent/received to the receiver. This is still wildly inaccurate
15// though.
16
17impl<T> DataSize for futures::channel::oneshot::Receiver<T> {
18    const IS_DYNAMIC: bool = false;
19    const STATIC_HEAP_SIZE: usize = size_of::<T>() + 3 * size_of::<usize>();
20
21    #[inline]
22    fn estimate_heap_size(&self) -> usize {
23        // Missing: Lock<Option<Waker>>, approximated by three pointers each.
24        Self::STATIC_HEAP_SIZE
25    }
26}