Rust configuration
These pages cover SDK generation configured with generators.yml. New projects use sdk-config.yml, so see the Current version of this page for up-to-date guidance. To move an existing project, follow the SDK Config migration guide, which walks through fern sdk migrate, and review the sdk-config.yml reference.
You can customize the behavior of the Rust SDK generator in generators.yml:
clientClassName
The name of the generated client struct. This allows you to customize the struct name that users will instantiate when using your SDK.
crateName
The name of the generated Rust crate. This is used in Cargo.toml and determines how users will add your SDK as a dependency. By default, hyphens become underscores in the package name (my-sdk publishes as my_sdk); set preserveCrateNameHyphens to keep them.
crateVersion
The version of the generated crate. This is used in Cargo.toml for publishing to crates.io.
dateTimeType
Determines how timezone information is handled:
offset: UsesDateTime<FixedOffset>to preserve the original timezone from API responsesutc: UsesDateTime<Utc>to normalize all datetimes to UTC regardless of their original timezone
Both options accept any datetime format and assume UTC if no timezone is provided in the datetime string.
environmentEnumName
The name of the generated environment enum. This allows you to customize the enum name that defines your API environments (such as production, staging, development).
enableWebsockets
Enable generation of WebSocket clients for APIs with WebSocket channels.
enableWireTests
When enabled, generates mock server (wire) tests to verify that the SDK sends the correct HTTP requests and correctly handles responses per the API spec.
generateExamples
When enabled, generates code examples in the README and reference documentation.
maxRetries
The default number of retries for failed requests. When not set, the generated SDK defaults to 3 retries. SDK users can still override this per-request via request options.
preserveCrateNameHyphens
Keeps hyphens from crateName in the Cargo package name. By default, the generator converts every run of hyphens and underscores to a single underscore, so crateName: my-sdk produces name = "my_sdk" in Cargo.toml. crates.io treats hyphenated and underscored spellings as the same crate, so enable this option when your crate is already published under a hyphenated name.
The hyphenated name applies to the Cargo.toml package name, the default description and docs.rs documentation URL, the default crates.io publish package name, and the README install snippet (cargo add my-sdk). The name is still lowercased, invalid characters are replaced, repeated separators are collapsed, and leading or trailing separators are trimmed. Rust code continues to import the crate by its underscored name (use my_sdk::prelude::*), since Cargo maps a hyphenated package name to an underscored library name. When crateName isn’t set, the default name derived from your organization and API name also keeps its hyphens.
respectOptionalRequestBody
Lets callers omit the request body on endpoints with an optional request body. The method takes the body as an Option, and a call that passes None sends no body and no Content-Type header, instead of an empty JSON object ({}). Enable this when your API treats a missing body differently from an empty one.
Only applies to request bodies declared as a single named type that the endpoint takes on its own. Required bodies, bodies folded into a request wrapper, and inlined request properties are unaffected.
userAgentFromPlatformHeaders
Sets the default ClientConfig.user_agent to the platform User-Agent value that Fern computes for the SDK, matching the other Fern SDKs. By default, the Rust SDK uses "<ApiName> Rust SDK" (the API name in PascalCase) and ignores the user-agent template.
With this option enabled, the default user agent is <package-name>/<version>, or the resolved user-agent template when one is set. The template supports the {packageName}, {version}, {language}, {generatorVersion}, {organization}, and {apiName} placeholders and is resolved at generation time.
This sets the default user agent to plantstore-rust-sdk/0.1.0. When Fern has no platform User-Agent value for the generation (for example, when the SDK version isn’t known), the default falls back to "<ApiName> Rust SDK".
Package metadata
Configure metadata for publishing to crates.io:
packageDescription
A description of the crate for crates.io. This appears in the crate’s metadata and search results.
packageLicense
The license identifier for the crate (e.g., “MIT”, “Apache-2.0”).
packageLicenseFile
Path to a custom license file (e.g., LICENSE.md). When set, uses license-file instead of license in Cargo.toml. This is useful when your license isn’t a standard Software Package Data Exchange (SPDX) identifier.
packageRepository
The URL of the crate’s source repository.
packageDocumentation
The URL of the crate’s documentation.
Dependencies
Add custom dependencies to your generated SDK:
extraDependencies
Additional dependencies to include in the generated Cargo.toml. Specify as a map of crate names to version requirements. You can also specify full dependency specifications with features and default features:
extraDevDependencies
Additional dev dependencies to include in the generated Cargo.toml. These are only used during development and testing.