fuchsia_component_test

Struct ScopedInstance

Source
pub struct ScopedInstance { /* private fields */ }
Expand description

RAII object that keeps a component instance alive until it’s dropped, and provides convenience functions for using the instance. Components v2 only.

Implementations§

Source§

impl ScopedInstance

Source

pub async fn new(coll: String, url: String) -> Result<Self, Error>

Creates and binds to a new component just like new_with_name, but uses an autogenerated name for the instance.

Source

pub async fn new_with_name( child_name: String, collection: String, url: String, ) -> Result<Self, Error>

Creates and binds to a new component named child_name in a collection coll with url, and returning an object that represents the component’s lifetime and can be used to access the component’s exposed directory. When the object is dropped, it will be asynchronously stopped and destroyed. This is useful for tests that wish to create components that should be torn down at the end of the test. Components v2 only.

Source

pub async fn is_started(&self) -> Result<bool, Error>

Returns true if the component is currently running.

Source

pub async fn start(&self) -> Result<ExecutionController, Error>

Starts the component. An error will be returned if the component is already running.

Source

pub async fn start_with_args( &self, args: StartChildArgs, ) -> Result<ExecutionController, Error>

Starts the component with the provided start arguments. An error will be returned if the component is already running.

Source

pub fn controller(&self) -> &ControllerProxy

Source

pub fn connect_to_binder(&self) -> Result<BinderProxy, Error>

Connect to exposed fuchsia.component.Binder protocol of instance, thus triggering it to start. Note: This will only work if the component exposes this protocol in its manifest.

Source

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

Same as connect_to_binder except that it will block until the component has started. Note: This function expects that the instance has not been started yet. If the instance has been started before this method is invoked, then this method will block forever waiting for the Started event. REQUIRED: The manifest of the component executing this code must use the “started” event_stream.

Source

pub fn connect_to_protocol_at_exposed_dir<P: DiscoverableProtocolMarker>( &self, ) -> Result<P::Proxy, Error>

Connect to an instance of a FIDL protocol hosted in the component’s exposed directory`,

Source

pub fn connect_to_named_protocol_at_exposed_dir<P: DiscoverableProtocolMarker>( &self, protocol_name: &str, ) -> Result<P::Proxy, Error>

Connect to an instance of a FIDL protocol hosted in the component’s exposed directory`,

Source

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

Connects to an instance of a FIDL protocol hosted in the component’s exposed directory using the given server_end.

Source

pub fn connect_request_to_named_protocol_at_exposed_dir( &self, protocol_name: &str, server_end: Channel, ) -> Result<(), Error>

Connects to an instance of a FIDL protocol called protocol_name hosted in the component’s exposed directory using the given server_end.

Source

pub fn get_exposed_dir(&self) -> &DirectoryProxy

Returns a reference to the component’s read-only exposed directory.

Source

pub fn destroy_waiter_taken(&self) -> bool

Returns true if take_destroy_waiter has already been called.

Source

pub fn take_destroy_waiter(&mut self) -> impl Future<Output = Result<(), Error>>

Returns a future which can be awaited on for destruction to complete after the ScopedInstance is dropped. Panics if called multiple times.

Source

pub fn child_name(&self) -> &str

Return the name of this instance.

Source

pub fn moniker(&self) -> String

Returns the moniker of this instance relative to the calling component.

Trait Implementations§

Source§

impl Drop for ScopedInstance

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

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, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

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 + Send + Sync>

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

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>,

Source§

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>,

Source§

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<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