space-lib
Documentation for how to use space-lib
Last updated
Was this helpful?
Documentation for how to use space-lib
Last updated
Was this helpful?
space-lib is a crate that abstracts the low level details of calling our custom host functions and includes some nice helper functions. The crate is located here: .
It currently includes a HTTP client that is used for sending requests and receiving responses to websites.
There are multiple ways to create a Request, and get
is one of them. There's also post
, delete
, head
, patch
and put
. To set a header field, use the set method like so:
For setting a query field, use the query
method. To send any data with the request, use any of these methods: send_bytes
, send_string
, send_form
and send_json
. Note that the type need to implement serde::Serialize
to be able to serialize them into json.
After creating the , use the call
method. This will call the request on the host system where the Web Assembly is running. After this, you will get a .
There are three methods that can be called on : into_vec
which returns Vec<u8>
, into_string
which returns Result<String>
and into_json
which returns Result<T>
where T: serde::DeserializeOwned.