Skip to content

Client Library (wc-api)

The wc-api crate is a Rust client library for the warecache REST API. It provides type-safe data structures and API communication, with C FFI bindings and Python bindings for use from other languages.

The source code is available at gitlab.slant.tech/open-source/warecache/wc-api.

Language Bindings

Language Interface Notes
Rust Native crate Direct dependency via Cargo
C wc-api.h header Generated by cbindgen
C++ wc-api-cpp.h header Generated by cbindgen
Python wc_api module Python bindings

Modules

The library is organized into modules matching the server's resource types.

Parts

Data structures and operations for parts management. Parts are identified by a part type and an internal part number (IPN).

BOMs

Bill of Materials management. BOMs contain versioned lists of items (parts with quantities and reference designators). Supports creating, editing, and versioning BOMs.

Projects

Project management. Projects contain versioned references to BOMs and sub-projects, representing a complete product assembly.

Containers

Container management. Containers are physical storage units (bins, shelves, etc.) that hold parts and contain sensors for inventory tracking.

Sensors

Sensor management. Sensors are mounted in containers and track part inventory levels.

Production

Production order management. Supports creating orders, tracking status through Draft, Active, Completed, and Cancelled states, and managing produced project instances.

Data Cache

Local data caching layer for offline operation and reducing API calls.

API Communication

HTTP client layer handling authentication, request building, and response parsing.

Installation

Clone the repository:

git clone https://gitlab.slant.tech/open-source/warecache/wc-api.git

Rust

Add to your Cargo.toml:

[dependencies]
wc-api = { path = "path/to/wc-api" }

C / C++

Build the library:

cd wc-api
cargo build --release

The shared library will be in target/release/. Include the generated header in your project:

#include "wc-api.h"

Python

The Python bindings use cffi ABI mode and require the shared library to be built first:

cd wc-api
cargo build --release
python3 python/scripts/generate_cdef.py
cd python
pip install .