'Adapt an L{asyncio.Future} to a L{Deferred}.
@note: This creates a L{Deferred} from a L{asyncio.Future}, I{not} from
a C{coroutine}; in other words, you will need to call
L{asyncio.async}, L{asyncio.ensure_future},
L{asyncio.AbstractEventLoop.create_task} or create an
L{asyncio.Task} yourself to get from a C{coroutine} to a
L{asyncio.Future} if what you have is an awaitable coroutine and
not a L{asyncio.Future}.  (The length of this list of techniques is
exactly why we have left it to the caller!)
@since: Twisted 17.5.0
@param future: The Future to adapt.
@type future: L{asyncio.Future}
@return: A Deferred which will fire when the Future fires.
@rtype: L{Deferred}'

@classmethod
def fromFuture(cls, future):

    def adapt(result):
        try:
            extracted = result.result()
        except:
            extracted = failure.Failure()
        adapt.actual.callback(extracted)
    futureCancel = object()
    def cancel(reself):
        future.cancel()
        reself.callback(futureCancel)
    self = cls(cancel)
    adapt.actual = self
    def uncancel(result):
        if (result is futureCancel):
            adapt.actual = Deferred()
            return adapt.actual
        return result
    self.addCallback(uncancel)
    future.add_done_callback(adapt)
    return self
