File: futures.rs

package info (click to toggle)
rust-datasize 0.2.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 172 kB
  • sloc: makefile: 4
file content (26 lines) | stat: -rw-r--r-- 723 bytes parent folder | download
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
    }
}