Google is committed to advancing racial equity for Black communities. See how.

wrap method

InterfaceHandle<T> wrap (T impl)

Returns an interface handle whose peer is bound to the given object.

Creates a channel pair, binds one of the channels to this object, and returns the other channel. Messages sent over the returned channel will be decoded and dispatched to impl.

The impl parameter must not be null.


InterfaceHandle<T> wrap(T impl) {
  if (!isUnbound) {
    throw FidlStateException("AsyncBinding<${$interfaceName}> isn't unbound");
  ChannelPair pair = ChannelPair();
  if (pair.status != ZX.OK) {
    throw Exception(
        "AsyncBinding<${$interfaceName}> couldn't create channel: ${getStringForStatus(pair.status)}");
  _impl = impl;

  state = InterfaceState.bound;

  return InterfaceHandle<T>(pair.second);