Struct netemul::TestInterface

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

A TestEndpoint that is installed in a realm’s Netstack.

Note that a TestInterface adds to the reference count of the underlying realm of its TestRealm. That is, a TestInterface that outlives the TestRealm it created is sufficient to keep the underlying realm alive.

Implementations§

source§

impl<'a> TestInterface<'a>

source

pub fn id(&self) -> u64

Gets the interface identifier.

source

pub fn endpoint(&self) -> &TestEndpoint<'a>

Returns the endpoint associated with the interface.

source

pub fn control(&self) -> &Control

Returns the interface’s control handle.

source

pub async fn get_authorization( &self ) -> Result<GrantForInterfaceAuthorization, Error>

Returns the authorization token for this interface.

source

pub fn connect_stack(&self) -> Result<StackProxy, Error>

Connects to fuchsia.net.stack in this interface’s realm.

source

pub async fn add_subnet_route(&self, subnet: Subnet) -> Result<(), Error>

Add a direct route from the interface to the given subnet.

source

pub async fn del_subnet_route(&self, subnet: Subnet) -> Result<(), Error>

Delete a direct route from the interface to the given subnet.

source

pub async fn add_default_route(&self, next_hop: IpAddress) -> Result<(), Error>

Add a default route through the given address.

source

pub async fn get_addrs( &self, included_addresses: IncludedAddresses ) -> Result<Vec<Address>, Error>

Gets the interface’s addresses.

source

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

Gets the interface’s device name.

source

pub async fn mac(&self) -> MacAddress

Gets the interface’s MAC address.

source

pub fn get_interface_event_stream( &self ) -> Result<impl Stream<Item = Result<Event, Error>>, Error>

Gets a stream of interface events yielded by calling watch on a new watcher.

The returned watcher will only return assigned addresses.

source

pub async fn start_dhcp<D: DhcpClient>(&self) -> Result<(), Error>

Starts DHCP on this interface.

source

pub async fn stop_dhcp<D: DhcpClient>(&self) -> Result<(), Error>

Stops DHCP on this interface.

source

pub async fn add_address(&self, subnet: Subnet) -> Result<(), Error>

Adds an address, waiting until the address assignment state is ASSIGNED.

source

pub async fn add_address_and_subnet_route( &self, subnet: Subnet ) -> Result<(), Error>

Adds an address and a subnet route, waiting until the address assignment state is ASSIGNED.

source

pub async fn del_address_and_subnet_route( &self, addr_with_prefix: Subnet ) -> Result<bool, Error>

Removes an address and a subnet route.

source

pub async fn remove_ipv6_linklocal_addresses( &self ) -> Result<Vec<Address>, Error>

Removes all IPv6 LinkLocal addresses on the interface.

Useful to purge the interface of autogenerated SLAAC addresses.

source

pub async fn set_ipv6_forwarding_enabled( &self, enabled: bool ) -> Result<(), Error>

Enable/disable IPv6 forwarding on this interface.

source

pub async fn set_ipv4_forwarding_enabled( &self, enabled: bool ) -> Result<(), Error>

Enable/disable IPv4 forwarding on this interface.

source

pub async fn remove( self ) -> Result<(EndpointProxy, Option<DeviceControlProxy>), Error>

Consumes this TestInterface and removes the associated interface in the Netstack, returning the device lifetime-carrying channels.

source

pub fn remove_device(self) -> (Control, Option<DeviceControlProxy>)

Consumes this TestInterface and removes the underlying device. The Netstack will implicitly remove the interface and clients can expect to observe a PEER_CLOSED event on the returned control channel.

source

pub async fn wait_removal(self) -> Result<InterfaceRemovedReason, Error>

Waits for this interface to signal that it’s been removed.

Methods from Deref<Target = EndpointProxy>§

source

pub fn take_event_stream(&self) -> EndpointEventStream

Get a Stream of events from the remote end of the protocol.

§Panics

Panics if the event stream was already taken.

source

pub fn get_config(&self) -> QueryResponseFut<EndpointConfig>

source

pub fn get_name(&self) -> QueryResponseFut<String>

Gets endpoint name.

Sends link up or down signal

source

pub fn get_port(&self, port: ServerEnd<PortMarker>) -> Result<(), Error>

Connects to the underlying device port.

source

pub fn get_proxy_( &self, proxy: ServerEnd<DeviceProxy_Marker> ) -> Result<(), Error>

Gets a proxy to open requests with zircon ethernet device.

Trait Implementations§

source§

impl<'a> Debug for TestInterface<'a>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> Deref for TestInterface<'a>

§

type Target = EndpointProxy

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TestInterface<'a>

§

impl<'a> Send for TestInterface<'a>

§

impl<'a> Sync for TestInterface<'a>

§

impl<'a> Unpin for TestInterface<'a>

§

impl<'a> !UnwindSafe for TestInterface<'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
§

impl<T> Encode<Ambiguous1> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _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> Encode<Ambiguous2> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _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, 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