blob: d2519e5e5926d8a23d72c508a1ef3f1224166989 [file] [log] [blame] [view]
# wrap method
[InterfaceHandle](../../package-fidl_fidl/InterfaceHandle-class.md)<T> wrap
(T impl)
<p>Returns an interface handle whose peer is bound to the given object.</p>
<p>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 <code>impl</code>.</p>
<p>The <code>impl</code> parameter must not be null.</p>
## Implementation
```dart
InterfaceHandle<T>? wrap(T impl) {
assert(!isBound);
ChannelPair pair = ChannelPair();
if (pair.status != ZX.OK) {
return null;
}
_impl = impl;
_reader.bind(pair.first!);
final callback = onBind;
if (callback != null) {
callback();
}
return InterfaceHandle<T>(pair.second);
}
```