See https://github.com/WP-API/WP-API/issues/926 for the previous story on this.
Though we want to discourage use of global state functions like these, there _is_ a REST_REQUEST constant for this purpose. As mentioned in that ticket, the idea of "the current request is a REST one" breaks down for things like _embed
requests, and internal rest_do_request
calls, therefore we don't want to encourage the use of "is the current request a REST one" as it's not always in that context.
@lots.0.logs perhaps you could define why you need such a function? wp_doing_ajax/cron()
are inherently process-level functions, but the REST API callback methods are not intended to scoped to the whole "page load" request.