1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use super::DataSize;
use core::mem::size_of;

impl<T> DataSize for futures::channel::oneshot::Sender<T> {
    const IS_DYNAMIC: bool = false;
    const STATIC_HEAP_SIZE: usize = 0;

    #[inline]
    fn estimate_heap_size(&self) -> usize {
        0
    }
}

// Note: We attribute the value to be sent/received to the receiver. This is still wildly inaccurate
// though.

impl<T> DataSize for futures::channel::oneshot::Receiver<T> {
    const IS_DYNAMIC: bool = false;
    const STATIC_HEAP_SIZE: usize = size_of::<T>() + 3 * size_of::<usize>();

    #[inline]
    fn estimate_heap_size(&self) -> usize {
        // Missing: Lock<Option<Waker>>, approximated by three pointers each.
        Self::STATIC_HEAP_SIZE
    }
}