Skip to content

Commit acecab2

Browse files
authored
Add README for typespec_macros (Azure#3046)
1 parent 9415bfe commit acecab2

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# TypeSpec Macros crate for Rust
2+
3+
The TypeSpec Macros crate provides procedural macros for [TypeSpec](https://typespec.io)-generated client libraries. These macros simplify the implementation of common patterns required when working with TypeSpec-generated code.
4+
5+
[Source code] | [Package (crates.io)] | [API reference documentation] | [TypeSpec documentation]
6+
7+
## Getting started
8+
9+
> **Note:** This crate should not be used directly. Users should depend on the `typespec_client_core` crate instead.
10+
11+
## Key concepts
12+
13+
This crate provides the following derive macros:
14+
15+
- `SafeDebug`: A derive macro that implements debug formatting in a way that avoids leaking personally identifiable information (PII).
16+
17+
### The SafeDebug derive macro
18+
19+
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.
20+
21+
## Examples
22+
23+
### Using the SafeDebug derive macro
24+
25+
```rust
26+
use typespec_macros::SafeDebug;
27+
28+
#[derive(SafeDebug)]
29+
struct Credentials {
30+
#[safe(true)]
31+
pub username: String,
32+
pub password: String,
33+
};
34+
let credentials: Credentials = Credentials {
35+
username: "admin".into(),
36+
password: "hunter2".into(),
37+
};
38+
println!("{credentials:?}");
39+
```
40+
41+
## Contributing
42+
43+
See the [CONTRIBUTING.md] for details on building, testing, and contributing to this library.
44+
45+
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/>.
46+
47+
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.
48+
49+
This project has adopted the [Microsoft Open Source Code of Conduct]. For more information see the [Code of Conduct FAQ] or contact <[email protected]> with any additional questions or comments.
50+
51+
[Source code]: https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/typespec/typespec_macros/src
52+
[Package (crates.io)]: https://crates.io/crates/typespec_macros
53+
[API reference documentation]: https://docs.rs/typespec_macros
54+
[TypeSpec documentation]: https://typespec.io/
55+
[CONTRIBUTING.md]: https://github.com/Azure/azure-sdk-for-rust/blob/main/CONTRIBUTING.md
56+
[Microsoft Open Source Code of Conduct]: https://opensource.microsoft.com/codeofconduct/
57+
[Code of Conduct FAQ]: https://opensource.microsoft.com/codeofconduct/faq/

sdk/typespec/typespec_macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
#![doc = include_str!("../README.md")]
45
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
56
#![warn(missing_docs)]
67

0 commit comments

Comments
 (0)