Struct netemul::TestRealm

source ·
pub struct TestRealm<'a> { /* private fields */ }
Expand description

A realm within a netemul sandbox.

Implementations§

source§

impl<'a> TestRealm<'a>

source

pub fn connect_to_protocol<S>(&self) -> Result<S::Proxy, Error>
where S: DiscoverableProtocolMarker,

Connects to a protocol within the realm.

source

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.

source

pub fn open_diagnostics_directory( &self, child_name: &str, ) -> Result<DirectoryProxy, Error>

Opens the diagnostics directory of a component.

source

pub fn connect_to_protocol_with_server_end<S: DiscoverableProtocolMarker>( &self, server_end: ServerEnd<S>, ) -> Result<(), Error>

Connects to a protocol within the realm.

source

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.

source

pub async fn get_moniker(&self) -> Result<String, Error>

Gets the moniker of the root of the managed realm.

source

pub async fn start_child_component(&self, child_name: &str) -> Result<(), Error>

Starts the specified child component of the managed realm.

source

pub async fn stop_child_component(&self, child_name: &str) -> Result<(), Error>

Stops the specified child component of the managed realm.

source

pub async fn join_network<S>( &self, network: &TestNetwork<'a>, ep_name: S, ) -> Result<TestInterface<'a>, Error>
where S: Into<Cow<'a, str>>,

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.

source

pub async fn join_network_with_if_config<S>( &self, network: &TestNetwork<'a>, ep_name: S, if_config: InterfaceConfig<'a>, ) -> Result<TestInterface<'a>, Error>
where S: Into<Cow<'a, str>>,

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub async fn add_virtual_device( &self, e: &TestEndpoint<'_>, path: &Path, ) -> Result<(), Error>

Adds a device to the realm’s virtual device filesystem.

source

pub async fn remove_virtual_device(&self, path: &Path) -> Result<(), Error>

Removes a device from the realm’s virtual device filesystem.

source

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.

source

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.

source

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.

source

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.

source

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 TestEndpoints, which components in the realm might be interacting with.

source

pub async fn icmp_socket<Ip: FuchsiaIpExt>( &self, ) -> Result<DatagramSocket, Error>

Constructs an ICMP socket.

source

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.

source

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.

source

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.

source

pub async fn main_table_id<I: FidlRouteIpExt + FidlRouteAdminIpExt>( &self, ) -> u32

Gets the table ID for the main route table.

Trait Implementations§

source§

impl<'a> Clone for TestRealm<'a>

source§

fn clone(&self) -> TestRealm<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for TestRealm<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

type Error = <U as TryFromExt<T>>::Error

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag