MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / drain_into_batch

Function drain_into_batch

nodedb-bridge/src/buffer.rs:386–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

384
385 #[test]
386 fn drain_into_batch() {
387 let (mut tx, mut rx) = RingBuffer::channel::<u64>(16);
388
389 for i in 0..10 {
390 tx.try_push(i).unwrap();
391 }
392
393 let mut buf = Vec::new();
394 let drained = rx.drain_into(&mut buf, 5);
395 assert_eq!(drained, 5);
396 assert_eq!(buf, vec![0, 1, 2, 3, 4]);
397
398 let drained = rx.drain_into(&mut buf, 100);
399 assert_eq!(drained, 5);
400 assert_eq!(buf, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
401 }
402
403 #[test]
404 fn disconnect_detection_producer_drops() {

Callers

nothing calls this directly

Calls 2

try_pushMethod · 0.80
drain_intoMethod · 0.45

Tested by

no test coverage detected