pub struct MemoryTransport { /* private fields */ }Expand description
An in-memory RaftTransport that records outgoing messages.
Instead of delivering anywhere, it appends each message to an outbox that a
test harness drains with take and routes to the
destination node by hand. This makes message ordering, loss, and partitions
something the test controls precisely.
§Examples
use raft_io::{MemoryTransport, RaftTransport, Message, AppendEntries};
let mut tx = MemoryTransport::new();
tx.send(2, Message::AppendEntries(AppendEntries {
term: 1, leader: 1, prev_log_index: 0, prev_log_term: 0,
entries: Vec::new(), leader_commit: 0,
})).unwrap();
let pending = tx.take();
assert_eq!(pending[0].0, 2); // destination
assert!(tx.take().is_empty()); // draining leaves it emptyImplementations§
Trait Implementations§
Source§impl Clone for MemoryTransport
impl Clone for MemoryTransport
Source§fn clone(&self) -> MemoryTransport
fn clone(&self) -> MemoryTransport
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryTransport
impl Debug for MemoryTransport
Source§impl Default for MemoryTransport
impl Default for MemoryTransport
Source§fn default() -> MemoryTransport
fn default() -> MemoryTransport
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryTransport
impl RefUnwindSafe for MemoryTransport
impl Send for MemoryTransport
impl Sync for MemoryTransport
impl Unpin for MemoryTransport
impl UnsafeUnpin for MemoryTransport
impl UnwindSafe for MemoryTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more