scconfig-rs
scconfig-rs is a production-oriented Rust library for consuming Spring Cloud Config Server from non-Spring applications.
It is built for Rust services that need:
- typed configuration loading from the standard Spring
Environmentendpoint - YAML and Java properties output from the alternative format endpoints
- arbitrary file retrieval through the plain-text resource endpoint
- binary-safe downloads for files such as
.p12,.jks, or any other non-text asset - a clean async API with explicit request models, error types, and documentation
What This Library Supports
Spring Cloud Config endpoints
GET /{application}/{profile}GET /{application}/{profile}/{label}GET /{application}/{profile}.ymlGET /{application}/{profile}.yamlGET /{application}/{profile}.propertiesGET /{application}/{profile}/{label}.ymlGET /{application}/{profile}/{label}.yamlGET /{application}/{profile}/{label}.propertiesGET /{application}/{profile}/{label}/{path}GET /{application}/{profile}/{path}?useDefaultLabel=true
Configuration format support
All file extensions are supported on the resource endpoint.
Built-in parsing and typed deserialization are available for:
- JSON
- YAML / YML
- TOML
- Java properties
Unknown extensions are still supported. The library returns them as UTF-8 text when possible, or as raw bytes otherwise.
Installation
From crates.io:
[]
= "0.1.3"
= { = "1", = ["derive"] }
= { = "1", = ["macros", "rt-multi-thread"] }
Quick Start
use ;
use Deserialize;
async
Alternative Format Example
use ;
async
Arbitrary File Example
use ;
async
Binary File Example
use ;
async
Bootstrap From Environment
use BootstrapConfig;
use Deserialize;
async
Supported bootstrap environment variables:
SPRING_CONFIG_SERVER_URLrequiredSPRING_APPLICATION_NAMErequiredSPRING_PROFILES_ACTIVEoptional, defaults todefaultSPRING_CONFIG_LABELoptionalSPRING_CONFIG_USERNAMEoptionalSPRING_CONFIG_PASSWORDoptionalSPRING_CONFIG_BEARER_TOKENoptionalSPRING_CONFIG_INSECURE_TLSoptional, defaults tofalseSPRING_CONFIG_TIMEOUT_SECSoptional
When bootstrapping against development Config Server endpoints that use private or
self-signed certificates, set SPRING_CONFIG_INSECURE_TLS=true to disable both
certificate and hostname validation for bootstrap requests only.
Development TLS
For local development or controlled smoke tests against self-signed or otherwise untrusted certificates, the builder can disable TLS validation explicitly:
use ;
async
Available builder methods:
danger_accept_invalid_certs(true)disables certificate validationdanger_accept_invalid_hostnames(true)disables hostname validationdanger_accept_invalid_tls(true)disables both
These options are unsafe for production and should only be used when you fully control the target environment.
Design Notes
- The
Environmentendpoint is the preferred source when you want typed Rust structs. - The library preserves Spring property-source precedence. Earlier property sources win.
- Labels containing
/are automatically encoded as(_), matching Spring Cloud Config server rules. - Resource downloads always request
application/octet-stream, which keeps binary retrieval safe without breaking text-based files. - Smart scalar coercion is enabled for typed binding. Strings such as
"8080"and"true"can bind to numeric and boolean fields.
Error Handling
All fallible operations return scconfig_rs::Error.
Errors include:
- invalid base URL or request input
- transport failures
- non-success HTTP responses with response body captured
- invalid JSON, YAML, TOML, or Java properties content
- UTF-8 decoding failures for text resources
- typed binding failures