libfetch 0.0.0
A lightweight asynchronous HTTP/1.1 client library implementing a subset of the WHATWG Fetch API.
Loading...
Searching...
No Matches
Promise State Accessors

Functions to inspect promise state and results. More...

Functions

fetch_response_tfetch_promise_response (const fetch_promise_t *promise)
 Get the response from a fulfilled promise.
 
fetch_promise_state_t fetch_promise_state (const fetch_promise_t *promise)
 Get the current state of a promise.
 
fetch_error_t fetch_promise_error (const fetch_promise_t *promise)
 Get the error code from a rejected promise.
 
const char * fetch_promise_error_message (const fetch_promise_t *promise)
 Get the error message from a rejected promise.
 
bool fetch_promise_pending (const fetch_promise_t *promise)
 Check if promise is still pending.
 
bool fetch_promise_fulfilled (const fetch_promise_t *promise)
 Check if promise was fulfilled successfully.
 
bool fetch_promise_rejected (const fetch_promise_t *promise)
 Check if promise was rejected.
 

Detailed Description

Functions to inspect promise state and results.

Function Documentation

◆ fetch_promise_error()

fetch_error_t fetch_promise_error ( const fetch_promise_t * promise)

Get the error code from a rejected promise.

Parameters
promiseThe promise
Returns
Error code

◆ fetch_promise_error_message()

const char * fetch_promise_error_message ( const fetch_promise_t * promise)

Get the error message from a rejected promise.

Parameters
promiseThe promise
Returns
Error message string (owned by promise), or NULL

◆ fetch_promise_fulfilled()

bool fetch_promise_fulfilled ( const fetch_promise_t * promise)

Check if promise was fulfilled successfully.

Parameters
promiseThe promise
Returns
true if fulfilled

◆ fetch_promise_pending()

bool fetch_promise_pending ( const fetch_promise_t * promise)

Check if promise is still pending.

Parameters
promiseThe promise
Returns
true if pending

◆ fetch_promise_rejected()

bool fetch_promise_rejected ( const fetch_promise_t * promise)

Check if promise was rejected.

Parameters
promiseThe promise
Returns
true if rejected

◆ fetch_promise_response()

fetch_response_t * fetch_promise_response ( const fetch_promise_t * promise)

Get the response from a fulfilled promise.

Parameters
promiseThe promise
Returns
Response object (owned by promise, do NOT free), or NULL if not fulfilled
Note
Memory: Response is owned by the promise, do not call fetch_response_free() on it

◆ fetch_promise_state()

fetch_promise_state_t fetch_promise_state ( const fetch_promise_t * promise)

Get the current state of a promise.

Parameters
promiseThe promise
Returns
Promise state