You will also need a `cdylib` build of the native library at runtime for the relevant platform. On Linux/macOS/BSD, this should be `target/release/libservicepoint2.so`.
As there is no API stability yet, your language binding has to match the used library version exactly.
### C
Copy the header to your project and compile against.
You have the choice of linking statically (recommended) or dynamically.
- The C example shows how to link statically against the `staticlib` variant.
- When linked dynamically, you have to provide the `cdylib` at runtime in the _same_ version, as there are no API/ABI guarantees yet.
## Examples
More are available in the `examples` folder.
### Rust
This is where the library works the best.
Any API usage accepted by the compiler in a safe context is either safe or buggy (issues welcome).
Uses C bindings internally to provide a similar API to rust. Things to keep in mind:
- You will get a `NullPointerException` when trying to call a method where the native instance has been consumed already (e.g. when `Send`ing a command instance twice). Send a clone instead of the original if you want to keep using it.
- Some lower-level APIs _will_ panic in native code when used improperly.
Example: manipulating the `Span<byte>` of an object after freeing the instance.
- C# specifics are documented in the library. Use the rust documentation for everything else. Naming and semantics are the same apart from CamelCase instead of kebap_case.
- You will only get rust backtraces in debug builds of the native code.
- F# is not explicitly tested. If there are usability or functionality problems, please open an issue.
```csharp
using ServicePoint2;
// using statement calls Dispose() on scope exit, which frees unmanaged instances
using var connection = Connection.Open("127.0.0.1:2342");
using var pixels = PixelGrid.New(Constants.PixelWidth, Constants.PixelHeight);
- tanks game (C#): https://github.com/kaesaecracker/cccb-tanks-cs
To add yourself to the list, open a pull request.
## Where is servicepoint1?
This library is a spiritual mix of a not-yet-working rust library called `servicepoint` and a bunch of working but also unfinished C# code. Because most of the API concept and a bunch of code is taken from the rust library, the result is called `servicepoint2`.
## Contributing
Contributions are accepted in any form (issues, documentation, feature requests, code, review, ...).