pub struct TestRealm<'a> { /* private fields */ }
Expand description
A realm within a netemul sandbox.
Implementations§
source§impl<'a> TestRealm<'a>
impl<'a> TestRealm<'a>
sourcepub fn connect_to_protocol<S>(&self) -> Result<S::Proxy, Error>where
S: DiscoverableProtocolMarker,
pub fn connect_to_protocol<S>(&self) -> Result<S::Proxy, Error>where
S: DiscoverableProtocolMarker,
Connects to a protocol within the realm.
sourcepub fn connect_to_protocol_from_child<S>(
&self,
child: &str,
) -> Result<S::Proxy, Error>where
S: DiscoverableProtocolMarker,
pub fn connect_to_protocol_from_child<S>(
&self,
child: &str,
) -> Result<S::Proxy, Error>where
S: DiscoverableProtocolMarker,
Connects to a protocol from a child within the realm.
sourcepub fn open_diagnostics_directory(
&self,
child_name: &str,
) -> Result<DirectoryProxy, Error>
pub fn open_diagnostics_directory( &self, child_name: &str, ) -> Result<DirectoryProxy, Error>
Opens the diagnostics directory of a component.
sourcepub fn connect_to_protocol_with_server_end<S: DiscoverableProtocolMarker>(
&self,
server_end: ServerEnd<S>,
) -> Result<(), Error>
pub fn connect_to_protocol_with_server_end<S: DiscoverableProtocolMarker>( &self, server_end: ServerEnd<S>, ) -> Result<(), Error>
Connects to a protocol within the realm.
sourcepub fn connect_to_protocol_from_child_at_path_with_server_end<S: DiscoverableProtocolMarker>(
&self,
protocol_path: &str,
child: &str,
server_end: ServerEnd<S>,
) -> Result<(), Error>
pub fn connect_to_protocol_from_child_at_path_with_server_end<S: DiscoverableProtocolMarker>( &self, protocol_path: &str, child: &str, server_end: ServerEnd<S>, ) -> Result<(), Error>
Connects to a protocol from a child at a path within the realm.
sourcepub async fn get_moniker(&self) -> Result<String, Error>
pub async fn get_moniker(&self) -> Result<String, Error>
Gets the moniker of the root of the managed realm.
sourcepub async fn start_child_component(&self, child_name: &str) -> Result<(), Error>
pub async fn start_child_component(&self, child_name: &str) -> Result<(), Error>
Starts the specified child component of the managed realm.
sourcepub async fn stop_child_component(&self, child_name: &str) -> Result<(), Error>
pub async fn stop_child_component(&self, child_name: &str) -> Result<(), Error>
Stops the specified child component of the managed realm.
sourcepub async fn join_network<S>(
&self,
network: &TestNetwork<'a>,
ep_name: S,
) -> Result<TestInterface<'a>, Error>
pub async fn join_network<S>( &self, network: &TestNetwork<'a>, ep_name: S, ) -> Result<TestInterface<'a>, Error>
Use default endpoint/interface configuration and the specified address configuration to create a test interface.
Characters may be dropped from the front of ep_name
if it exceeds the
maximum length.
sourcepub async fn join_network_with_if_config<S>(
&self,
network: &TestNetwork<'a>,
ep_name: S,
if_config: InterfaceConfig<'a>,
) -> Result<TestInterface<'a>, Error>
pub async fn join_network_with_if_config<S>( &self, network: &TestNetwork<'a>, ep_name: S, if_config: InterfaceConfig<'a>, ) -> Result<TestInterface<'a>, Error>
Use default endpoint configuration and the specified interface/address configuration to create a test interface.
Characters may be dropped from the front of ep_name
if it exceeds the
maximum length.
sourcepub async fn join_network_with(
&self,
network: &TestNetwork<'a>,
ep_name: impl Into<Cow<'a, str>>,
ep_config: EndpointConfig,
if_config: InterfaceConfig<'a>,
) -> Result<TestInterface<'a>, Error>
pub async fn join_network_with( &self, network: &TestNetwork<'a>, ep_name: impl Into<Cow<'a, str>>, ep_config: EndpointConfig, if_config: InterfaceConfig<'a>, ) -> Result<TestInterface<'a>, Error>
Joins network
with by creating an endpoint with ep_config
and
installing it into the realm with if_config
.
Returns a TestInterface
corresponding to the added interface. The
interface is guaranteed to have its link up and be enabled when this
async function resolves.
Note that this realm needs a Netstack for this operation to succeed.
Characters may be dropped from the front of ep_name
if it exceeds the maximum length.
sourcepub async fn join_network_with_installer(
&self,
network: &TestNetwork<'a>,
installer: InstallerProxy,
interface_state: StateProxy,
ep_name: impl Into<Cow<'a, str>>,
ep_config: EndpointConfig,
if_config: InterfaceConfig<'a>,
) -> Result<(TestEndpoint<'a>, u64, Control, DeviceControlProxy), Error>
pub async fn join_network_with_installer( &self, network: &TestNetwork<'a>, installer: InstallerProxy, interface_state: StateProxy, ep_name: impl Into<Cow<'a, str>>, ep_config: EndpointConfig, if_config: InterfaceConfig<'a>, ) -> Result<(TestEndpoint<'a>, u64, Control, DeviceControlProxy), Error>
Joins network
by creating an endpoint with ep_config
and installing it with
installer
and if_config
.
This inherits the lifetime of self
, so there’s an assumption that installer
is served
by something in this TestRealm
, but there’s nothing enforcing this.
Returns the created endpoint, the interface ID, and the associated interface
[Control
] and fnet_interfaces_admin::DeviceControlProxy
.
Characters may be dropped from the front of ep_name
if it exceeds the maximum length.
sourcepub async fn install_endpoint_with_installer(
&self,
installer: InstallerProxy,
interface_state: StateProxy,
endpoint: &TestEndpoint<'a>,
if_config: InterfaceConfig<'a>,
) -> Result<(u64, Control, DeviceControlProxy), Error>
pub async fn install_endpoint_with_installer( &self, installer: InstallerProxy, interface_state: StateProxy, endpoint: &TestEndpoint<'a>, if_config: InterfaceConfig<'a>, ) -> Result<(u64, Control, DeviceControlProxy), Error>
Installs and configures the endpoint as an interface. Uses interface_state
to observe that
the interface is up after it is installed.
This inherits the lifetime of self
, so there’s an assumption that installer
is served
by something in this TestRealm
, but there’s nothing enforcing this.
Note that if name
is not None
, the string must fit within interface name limits.
sourcepub async fn install_endpoint(
&self,
endpoint: TestEndpoint<'a>,
if_config: InterfaceConfig<'a>,
) -> Result<TestInterface<'a>, Error>
pub async fn install_endpoint( &self, endpoint: TestEndpoint<'a>, if_config: InterfaceConfig<'a>, ) -> Result<TestInterface<'a>, Error>
Installs and configures the endpoint in this realm.
Note that if name
is not None
, the string must fit within interface name limits.
sourcepub async fn add_raw_device(
&self,
path: &Path,
device: ClientEnd<DeviceProxy_Marker>,
) -> Result<(), Error>
pub async fn add_raw_device( &self, path: &Path, device: ClientEnd<DeviceProxy_Marker>, ) -> Result<(), Error>
Adds a raw device connector to the realm’s devfs.
sourcepub async fn add_virtual_device(
&self,
e: &TestEndpoint<'_>,
path: &Path,
) -> Result<(), Error>
pub async fn add_virtual_device( &self, e: &TestEndpoint<'_>, path: &Path, ) -> Result<(), Error>
Adds a device to the realm’s virtual device filesystem.
sourcepub async fn remove_virtual_device(&self, path: &Path) -> Result<(), Error>
pub async fn remove_virtual_device(&self, path: &Path) -> Result<(), Error>
Removes a device from the realm’s virtual device filesystem.
sourcepub async fn datagram_socket(
&self,
domain: Domain,
proto: DatagramSocketProtocol,
) -> Result<Socket, Error>
pub async fn datagram_socket( &self, domain: Domain, proto: DatagramSocketProtocol, ) -> Result<Socket, Error>
Creates a Datagram [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket/Provider
in this realm.
sourcepub async fn raw_socket(
&self,
domain: Domain,
association: ProtocolAssociation,
) -> Result<Socket, Error>
pub async fn raw_socket( &self, domain: Domain, association: ProtocolAssociation, ) -> Result<Socket, Error>
Creates a raw [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket.raw/Provider
in this realm.
sourcepub async fn packet_socket(&self, kind: Kind) -> Result<Socket, Error>
pub async fn packet_socket(&self, kind: Kind) -> Result<Socket, Error>
Creates a [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket.packet/Provider
in this realm.
sourcepub async fn stream_socket(
&self,
domain: Domain,
proto: StreamSocketProtocol,
) -> Result<Socket, Error>
pub async fn stream_socket( &self, domain: Domain, proto: StreamSocketProtocol, ) -> Result<Socket, Error>
Creates a Stream [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket/Provider
in this realm.
sourcepub async fn shutdown(&self) -> Result<(), Error>
pub async fn shutdown(&self) -> Result<(), Error>
Shuts down the realm.
It is often useful to call this method to ensure that the realm
completes orderly shutdown before allowing other resources to be dropped
and get cleaned up, such as TestEndpoint
s, which components in the
realm might be interacting with.
sourcepub async fn icmp_socket<Ip: FuchsiaIpExt>(
&self,
) -> Result<DatagramSocket, Error>
pub async fn icmp_socket<Ip: FuchsiaIpExt>( &self, ) -> Result<DatagramSocket, Error>
Constructs an ICMP socket.
sourcepub async fn ping_once<Ip: FuchsiaIpExt>(
&self,
addr: Ip::SockAddr,
seq: u16,
) -> Result<(), Error>
pub async fn ping_once<Ip: FuchsiaIpExt>( &self, addr: Ip::SockAddr, seq: u16, ) -> Result<(), Error>
Sends a single ICMP echo request to addr
, and waits for the echo reply.
sourcepub async fn add_neighbor_entry(
&self,
interface: u64,
addr: IpAddress,
mac: MacAddress,
) -> Result<(), Error>
pub async fn add_neighbor_entry( &self, interface: u64, addr: IpAddress, mac: MacAddress, ) -> Result<(), Error>
Add a static neighbor entry.
Useful to prevent NUD resolving too slow and causing spurious test failures.
sourcepub fn get_interface_event_stream(
&self,
) -> Result<impl Stream<Item = Result<Event, Error>>, Error>
pub fn get_interface_event_stream( &self, ) -> Result<impl Stream<Item = Result<Event, Error>>, Error>
Get a stream of interface events from a new watcher.
sourcepub async fn main_table_id<I: FidlRouteIpExt + FidlRouteAdminIpExt>(
&self,
) -> u32
pub async fn main_table_id<I: FidlRouteIpExt + FidlRouteAdminIpExt>( &self, ) -> u32
Gets the table ID for the main route table.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TestRealm<'a>
impl<'a> !RefUnwindSafe for TestRealm<'a>
impl<'a> Send for TestRealm<'a>
impl<'a> Sync for TestRealm<'a>
impl<'a> Unpin for TestRealm<'a>
impl<'a> !UnwindSafe for TestRealm<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)