Struct holochain::prelude::test_util::switchboard_state::Switchboard
source · pub struct Switchboard { /* private fields */ }
Expand description
Wrapper around the shared state for a Switchboard network. This state represents the shared state across all nodes in a space.
This is essentially an Arc<Clone<SwitchboardState>>
, which is passed to
SwitchboardEventHandler and is also accessible to your test, so that you can
manually modify state while gossip is modifying the same state.
When calling add_node(s)
, a new gossip module is created, a task is
spawned to feed incoming network messages to the gossip module, and another
task is spawned which handles the events received, mutating the state
in the process.
Implementations§
source§impl Switchboard
impl Switchboard
sourcepub fn new(topology: Topology, gossip_type: GossipType) -> Switchboard
pub fn new(topology: Topology, gossip_type: GossipType) -> Switchboard
Constructor. Only works for one GossipType at a time.
Simple infallible combinator around share_mut
, more convenient
for tests.
sourcepub async fn add_nodes<const N: usize>(
&self,
tuning_params: Arc<KitsuneP2pTuningParams>
) -> impl Future<Output = [Tx2EpHnd<Wire>; N]>
pub async fn add_nodes<const N: usize>( &self, tuning_params: Arc<KitsuneP2pTuningParams> ) -> impl Future<Output = [Tx2EpHnd<Wire>; N]>
Convenience for creating multiple nodes at once, easily destructurable using array syntax:
// no need to specify the number, the destructuring will deduce that.
let [n1, n2, n3] = sb.add_nodes();
Trait Implementations§
source§impl Clone for Switchboard
impl Clone for Switchboard
source§fn clone(&self) -> Switchboard
fn clone(&self) -> Switchboard
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Switchboard
impl Send for Switchboard
impl Sync for Switchboard
impl Unpin for Switchboard
impl !UnwindSafe for Switchboard
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.