pub struct TestSandbox { /* private fields */ }Expand description
A test sandbox backed by a fnetemul::SandboxProxy.
TestSandbox provides various utility methods to set up network realms for
use in testing. The lifetime of the TestSandbox is tied to the netemul
sandbox itself, dropping it will cause all the created realms, networks, and
endpoints to be destroyed.
Implementations§
Source§impl TestSandbox
impl TestSandbox
Sourcepub fn new() -> Result<TestSandbox, Error>
pub fn new() -> Result<TestSandbox, Error>
Creates a new empty sandbox.
Sourcepub fn create_realm<'a, I>(
&'a self,
name: impl Into<Cow<'a, str>>,
children: I,
) -> Result<TestRealm<'a>, Error>
pub fn create_realm<'a, I>( &'a self, name: impl Into<Cow<'a, str>>, children: I, ) -> Result<TestRealm<'a>, Error>
Creates a realm with name and children.
Sourcepub fn create_empty_realm<'a>(
&'a self,
name: impl Into<Cow<'a, str>>,
) -> Result<TestRealm<'a>, Error>
pub fn create_empty_realm<'a>( &'a self, name: impl Into<Cow<'a, str>>, ) -> Result<TestRealm<'a>, Error>
Creates a realm with no components.
Sourcepub fn get_network_manager(&self) -> Result<NetworkManagerProxy, Error>
pub fn get_network_manager(&self) -> Result<NetworkManagerProxy, Error>
Connects to the sandbox’s NetworkManager.
Sourcepub fn get_endpoint_manager(&self) -> Result<EndpointManagerProxy, Error>
pub fn get_endpoint_manager(&self) -> Result<EndpointManagerProxy, Error>
Connects to the sandbox’s EndpointManager.
Sourcepub async fn create_network<'a>(
&'a self,
name: impl Into<Cow<'a, str>>,
) -> Result<TestNetwork<'a>, Error>
pub async fn create_network<'a>( &'a self, name: impl Into<Cow<'a, str>>, ) -> Result<TestNetwork<'a>, Error>
Creates a new empty network with default configurations and name.
Sourcepub async fn setup_networks<'a>(
&'a self,
networks: Vec<NetworkSetup>,
) -> Result<TestNetworkSetup<'a>, Error>
pub async fn setup_networks<'a>( &'a self, networks: Vec<NetworkSetup>, ) -> Result<TestNetworkSetup<'a>, Error>
Creates new networks and endpoints as specified in networks.
Sourcepub async fn create_endpoint<'a, S>(
&'a self,
name: S,
) -> Result<TestEndpoint<'a>, Error>
pub async fn create_endpoint<'a, S>( &'a self, name: S, ) -> Result<TestEndpoint<'a>, Error>
Creates a new unattached endpoint with default configurations and name.
Characters may be dropped from the front of name if it exceeds the maximum length.
Sourcepub async fn create_endpoint_with<'a>(
&'a self,
name: impl Into<Cow<'a, str>>,
config: EndpointConfig,
) -> Result<TestEndpoint<'a>, Error>
pub async fn create_endpoint_with<'a>( &'a self, name: impl Into<Cow<'a, str>>, config: EndpointConfig, ) -> Result<TestEndpoint<'a>, Error>
Creates a new unattached endpoint with the provided configuration.
Characters may be dropped from the front of name if it exceeds the maximum length.
Auto Trait Implementations§
impl Freeze for TestSandbox
impl !RefUnwindSafe for TestSandbox
impl Send for TestSandbox
impl Sync for TestSandbox
impl Unpin for TestSandbox
impl !UnwindSafe for TestSandbox
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
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more