Skip to content

Commit

Permalink
🔧 Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nwrenger committed Jul 31, 2024
1 parent 2b938c1 commit 3647bde
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
gluer = "0.4.0"
gluer = "0.4.1"
```

## Features
Expand All @@ -27,6 +27,7 @@ Note: This crate is in an early stage and may not work in all cases. Please open
- Infer input and output types of functions.
- Support `axum`'s types completely.
- Convert Rust structs to TypeScript interfaces.
- Via the `[#metadata]` attribute macro with the `#[meta(...)]` attribute
- Generate a TypeScript file with:
- Functions
- Data types as Interfaces
Expand All @@ -38,7 +39,7 @@ Note: This crate is in an early stage and may not work in all cases. Please open

### Step 1: Define Structs and Functions

Use the `#[metadata]` macro to define your data structures and functions. This macro allows `gluer` to generate metadata for these structs and functions as `const` values with the same visibility as the function or struct. When splitting these into other modules, you need to import these `const` values, but they are recognized by Rust's compiler, so there is no need to worry about that.
Use the `#[metadata]` macro with the `#[meta(...)]` attribute to define your data structures and functions. This macro allows `gluer` to generate metadata for these structs and functions as `const` values with the same visibility as the function or struct. When splitting these into other modules, you need to import these `const` values, but they are recognized by Rust's compiler, so there is no need to worry about that.

```rust
use axum::{
Expand All @@ -51,8 +52,8 @@ use gluer::metadata;
#[derive(Default, serde::Serialize)]
struct Book {
name: String,
// Sometimes you don't have access to certain data types, so you can override them using `#[into(Type)]`
#[into(String)]
// Sometimes you don't have access to certain data types, so you can override them using `#[meta(into = Type)]` or skip the entirely via `#[meta(skip)]`
#[meta(into = String)]
user: User,
}

Expand Down Expand Up @@ -163,7 +164,7 @@ pub struct Hello<T: Serialize> {
#[metadata]
#[derive(Serialize, Deserialize, Default)]
struct Age {
#[into(String)]
#[meta(into = String)]
age: AgeInner,
}

Expand Down

0 comments on commit 3647bde

Please sign in to comment.