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> Encode<Ambiguous1> for T

source§

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> Encode<Ambiguous2> for T

source§

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