FastComments Rust SDK
The official Rust SDK for FastComments, a fast and developer-friendly commenting platform. This SDK provides typed API clients and utilities for integrating FastComments into your Rust applications.
Installation
The SDK requires Rust 2021 edition or later.
Library Contents
The FastComments Rust SDK consists of several modules:
-
Client Module - API client for FastComments REST APIs
- Complete type definitions for all API models
- Three API clients covering all FastComments methods:
default_api(DefaultApi) - API-key-authenticated methods for server-side usepublic_api(PublicApi) - public, no-API-key methods that are safe to call from browsers and mobile appsmoderation_api(ModerationApi) - methods backing the moderator dashboard, including comment moderation (list, count, search, logs, export), moderation actions (remove/restore, flag, set review/spam/approval status, votes, reopen/close thread), bans (ban from a comment, undo, pre-ban summaries, ban status/preferences, banned-user counts), and badges & trust (award/remove badges, manual badges, get/set trust factor, user internal profile). Every Moderation method accepts anssoparameter so the call can be made on behalf of an SSO-authenticated moderator.
- Full async/await support with tokio
- See client/README.md for detailed API documentation
-
SSO Module - Server-side Single Sign-On utilities
- Secure token generation for user authentication
- Support for both simple and secure SSO modes
- HMAC-SHA256 based token signing
-
Core Types - Shared type definitions and utilities
- Comment models and metadata structures
- User and tenant configurations
- Helper functions for common operations
Quick Start
Using the Public API
use Configuration;
use public_api;
async
Using the Authenticated API
use ;
use default_api;
async
Using the Moderation API
The moderation methods back the moderator dashboard. They use an API-key Configuration just like the authenticated API, and each method accepts an optional sso token so the call can be made on behalf of an SSO-authenticated moderator.
use ;
use moderation_api;
async
Using SSO for Authentication
use ;
Common Issues
401 Unauthorized Errors
If you're getting 401 errors when using the authenticated API:
- Check your API key: Ensure you're using the correct API key from your FastComments dashboard
- Verify the tenant ID: Make sure the tenant ID matches your account
- API key format: The API key should be passed in the Configuration:
let mut config = new;
config.api_key = Some;
SSO Token Issues
If SSO tokens aren't working:
- Use secure mode for production: Always use
FastCommentsSSO::new_secure()with your API key for production - Server-side only: Generate SSO tokens on your server, never expose your API key to clients
- Check user data: Ensure all required fields (id, email, username) are provided
Async Runtime Errors
The SDK uses tokio for async operations. Make sure to:
- Add tokio to your dependencies:
[]
= { = "1", = ["full"] }
- Use the tokio runtime:
async
Notes
Broadcast IDs
You'll see you're supposed to pass a broadcastId in some API calls. When you receive events, you'll get this ID back, so you know to ignore the event if you plan to optimistically apply changes on the client
(which you'll probably want to do since it offers the best experience). Pass a UUID here. The ID should be unique enough to not occur twice in a browser session.
Support
For issues, questions, or feature requests:
- GitHub Issues: https://github.com/fastcomments/fastcomments-rust
- Documentation: https://docs.fastcomments.com
- Support: support@fastcomments.com
License
MIT - See LICENSE file for details.