| Crates.io | typespec_macros |
| lib.rs | typespec_macros |
| version | 0.10.0 |
| created_at | 2025-02-18 21:15:42.765756+00 |
| updated_at | 2026-01-19 18:57:14.855914+00 |
| description | Procedural macros for client libraries built on typespec. |
| homepage | https://typespec.io |
| repository | https://github.com/azure/azure-sdk-for-rust |
| max_upload_size | |
| id | 1560470 |
| size | 35,055 |
The TypeSpec Macros crate provides procedural macros for TypeSpec-generated client libraries. These macros simplify the implementation of common patterns required when working with TypeSpec-generated code.
Source code | Package (crates.io) | API reference documentation | TypeSpec documentation
Note: This crate should not be used directly. Users should depend on the
typespec_client_corecrate instead.
This crate provides the following derive macros:
SafeDebug: A derive macro that implements debug formatting in a way that avoids leaking personally identifiable information (PII).The SafeDebug derive macro creates a Debug implementation that respects the #[safe(true)] and #[safe(false)] attribute on struct fields. By default fields are considered sensitive and will not have their values printed in debug output, protecting potentially sensitive information.
use typespec_macros::SafeDebug;
#[derive(SafeDebug)]
struct Credentials {
#[safe(true)]
pub username: String,
pub password: String,
};
let credentials = Credentials {
username: "admin".into(),
password: "hunter2".into(),
};
#[cfg(not(feature = "debug"))]
assert_eq!(
format!("{credentials:?}"),
r#"Credentials { username: "admin", .. }"#,
);
#[cfg(feature = "debug")]
assert_eq!(
format!("{credentials:?}"),
r#"Credentials { username: "admin", password: "hunter2" }"#,
);
See the CONTRIBUTING.md for details on building, testing, and contributing to this library.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://opensource.microsoft.com/cla/.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.