Skip to content

dezentrale/spaceapi-rs

 
 

Repository files navigation

Rust SpaceAPI Implementation of dezentrale

This is an implementation of the SpaceAPI v14 in Rust. It contains following parts

  • spaceapi-dezentrale: Serialization and deserialization to/from JSON using Serde
  • spaceapi-dezentrale-client: Client to access the server via API
  • spaceapi-dezentrale-server: Server which provides the API

Supported architectures with static linked binaries with musl libc:

  • x86-64
  • Aarch64
  • ARMv6 + FPU
  • ARMv7 + FPU

Build

cargo build --release

Usage

Server

Create a config file (see config.sample.yml) which describes some basic information about the space, see below.

Start the server.

CONFIG_FILE=config.sample.yml RUST_LOG=INFO \
    spaceapi-dezentrale-server

Configuration file

The publish section is a representation of the Status struct of the SpaceAPI, which will be used as a template for publishing the status.

The server doesn't use much custom logic. See Rocket documentation how to change parts like ports, limits, etc.

The log level can be changed with the default mechanism of RUST_LOG of env_logger.

Client

Open the space

SPACEAPI_URL=http://localhost:8000 API_KEY=not-very-secure \
    spaceapi-dezentrale-client open

Close the space

SPACEAPI_URL=http://localhost:8000 API_KEY=not-very-secure \
    spaceapi-dezentrale-client close

Check if the space is open

SPACEAPI_URL=http://localhost:8000 API_KEY=not-very-secure \
    spaceapi-dezentrale-client is-open

Keep open call

SPACEAPI_URL=http://localhost:8000 API_KEY=not-very-secure \
    spaceapi-dezentrale-client keep-open

Containter images

Due the support for static linked binaries the container images are based on the scratch image so the image only contains the binary.

To build the images for x86-64:

# Build the server image
docker build -f docker/Docker.server -t spaceapi-dezentrale-server .

# Build the client image
docker build -f docker/Docker.client -t spaceapi-dezentrale-client .

To build other configurations and architectures take a look into Dockerfile and the GitHub release workflow.

License

Licensed under either of

at your option.