diff --git a/.gitignore b/.gitignore index f74c781..09c9f64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .next node_modules +.idea diff --git a/mint.json b/mint.json index 357bb59..b1dfc4d 100644 --- a/mint.json +++ b/mint.json @@ -92,7 +92,8 @@ { "group": "Go", "pages": ["sdks/server/go-api", "sdks/server/go-leap"] - } + }, + "sdks/server/rs" ] } ] diff --git a/reference/project-tokens.mdx b/reference/project-tokens.mdx index 8daf2db..652ecd2 100644 --- a/reference/project-tokens.mdx +++ b/reference/project-tokens.mdx @@ -67,6 +67,18 @@ func main() { } ```` +```rs Rust +extern crate hop; + +use hop::Hop; + +#[tokio::main] +async fn main() { + let my_token = "ptk_xxx"; + let hop = Hop::new(my_token); +} +```` + ### API diff --git a/sdks/overview.mdx b/sdks/overview.mdx index cd120fe..6b5008d 100644 --- a/sdks/overview.mdx +++ b/sdks/overview.mdx @@ -19,6 +19,7 @@ languages. Below is a list of our official, supported libraries. | ---------- | ---------- | ------------------------------------------------------------------------ | -------- | ------------------------------------------ | | @onehop/js | TypeScript | [npmjs.com/package/@onehop/js](https://www.npmjs.com/package/@onehop/js) | ✅ | [/sdks/server/js](/sdks/server/js) | | hop-go | Golang | [github.com/hopinc/go](https://github.com/hopinc/go) | ✅ | [/sdks/server/go-api](/sdks/server/go-api) | +| hop-rs | Rust | [github.com/hopinc/rs](https://github.com/hopinc/rs) | ✅ | [/sdks/server/rs-api](/sdks/server/rs-api) | ### REST API diff --git a/sdks/server/rs.mdx b/sdks/server/rs.mdx new file mode 100644 index 0000000..4ca6ae6 --- /dev/null +++ b/sdks/server/rs.mdx @@ -0,0 +1,43 @@ +--- +title: 'Server-side Rust SDK' +sidebarTitle: 'Rust' +description: + 'The Hop server-side Rust SDK allows you to interact with all Hop products on + the server side.' +--- + +## Installing + +You can add `hop-rs` to your `cargo.toml` file: + +```toml TOML +[dependencies] +hop-rs = "0.1.0" +``` + +## Creating an SDK Instance + +To use the SDK, you must first create a +[project token](/reference/project-tokens). You can also use a PAT (personal +access token), however this is not recommended as it has access to all of your +projects. + +```rust RS +extern crate hop; +extern crate rand; + +use hop::Hop; +use rand::Rng; + +#[tokio::main] +async fn main() { + let my_token = "ptk_xxx"; + let hop = Hop::new(my_token); + + // Example: Creating a project secret + hop.projects.create_secret( + "RANDOM_NUMBER", + rand::thread_rng().gen_range(0..100).to_string(), + ).await.unwrap(); +} +```