-
Notifications
You must be signed in to change notification settings - Fork 192
Rust SDK #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
PineappleIOnic
wants to merge
48
commits into
appwrite:master
from
PineappleIOnic:rust-language-support
Closed
Rust SDK #137
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
92e5406
Start work on client
PineappleIOnic 1fa69ba
Add formdata and json to call() on client
PineappleIOnic 96ae155
Create basic twig templates
PineappleIOnic c9048f6
Fix accidental NodeJS Template Change
PineappleIOnic 50d4cb8
Finish Template
PineappleIOnic 66169af
Add Readme and user-agent header
PineappleIOnic 9f56d8b
Fix Licence Name in cargo.toml and Indentation in the twig templates
PineappleIOnic a43d7af
fix whitespace
TorstenDittmann 070a10c
Remove Hardcoded Package Name
PineappleIOnic fbeeb7f
Merge branch 'rust-language-support' of https://github.com/PineappleI…
PineappleIOnic 8d3bbba
Fix imports that were missed when changing to variable package name
PineappleIOnic 07499a8
Make arrays easier to use by using borrowed arrays
PineappleIOnic 28a3658
Add example generation
PineappleIOnic 09aeab3
Merge branch 'master' into rust-language-support
PineappleIOnic c0bb109
Remove Java from SDKTests
PineappleIOnic 447ba46
fix tests
PineappleIOnic 918e4f1
First implementation of Exceptions
PineappleIOnic 5d5f559
Add tests for exceptions
PineappleIOnic 64a081b
Fix hardcoded exception
PineappleIOnic 116d3d7
Only return underlying error when we fail to parse a Appwrite API Error
PineappleIOnic 23e3f9e
Merge branch 'master' into rust-language-support
TorstenDittmann 601dc43
Update test to add Test Started message
PineappleIOnic f346316
Update templates/rust/src/client.rs.twig
PineappleIOnic 3cccccd
Add cookies feature on reqwest
PineappleIOnic a1f6745
Update templates/rust/src/services/service.rs.twig
PineappleIOnic 434cb04
Add add_self_signed function to Client in SDK and Remove Cookies
PineappleIOnic d79ba01
Merge branch 'master' into rust-language-support
PineappleIOnic 5fa73cd
Update SDKTest.php
PineappleIOnic 8874c2a
Merge branch 'master' into rust-language-support
PineappleIOnic 6d3d35f
Merge branch 'appwrite:master' into rust-language-support
PineappleIOnic 45f2977
Add text error fallback
PineappleIOnic 694311e
Merge branch 'master' into rust-language-support
PineappleIOnic b7fbda3
Merge branch 'appwrite:master' into rust-language-support
PineappleIOnic ebe5153
Merge branch 'master' into rust-language-support
PineappleIOnic dc6d216
Bring up to date with master
PineappleIOnic 583a0da
Add Floats
PineappleIOnic b02485d
Implement Optional Parameters into Rust SDK
PineappleIOnic e11a6f9
Merge branch 'master' into rust-language-support
PineappleIOnic 1ab01c9
Update service.rs.twig
PineappleIOnic eb42bbd
Merge branch 'master' into rust-language-support
PineappleIOnic ce4ca0c
Merge branch 'master' into rust-language-support
PineappleIOnic 20a8d84
tests(rust): improvements
TorstenDittmann a1cfba2
revert whitelist
TorstenDittmann 6815c8d
Merge pull request #4 from TorstenDittmann/rust-language-support-impr…
PineappleIOnic 4eea144
Update SDKTest.php
PineappleIOnic abf62b5
Update Cargo.toml.twig
PineappleIOnic 65f5071
Merge branch 'master' into rust-language-support
PineappleIOnic 038a697
Merge branch 'master' into rust-language-support
PineappleIOnic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,262 @@ | ||
| <?php | ||
|
|
||
| namespace Appwrite\SDK\Language; | ||
|
|
||
| use Appwrite\SDK\Language; | ||
|
|
||
| class Rust extends Language { | ||
| /** | ||
| * @var array | ||
| */ | ||
| protected $params = [ | ||
| 'packageName' => 'packageName', | ||
| ]; | ||
|
|
||
| /** | ||
| * @param string $name | ||
| * @return $this | ||
| */ | ||
| public function setPackageName($name) | ||
| { | ||
| $this->setParam('packageName', $name); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getName() | ||
| { | ||
| return 'Rust'; | ||
| } | ||
|
|
||
| /** | ||
| * Get Language Keywords List | ||
| * | ||
| * @return array | ||
| */ | ||
| public function getKeywords() | ||
| { | ||
| return [ | ||
| "type", | ||
| "as", | ||
| "break", | ||
| "const", | ||
| "continue", | ||
| "crate", | ||
| "else", | ||
| "enum", | ||
| "extern", | ||
| "false", | ||
| "fn", | ||
| "for", | ||
| "if", | ||
| "impl", | ||
| "in", | ||
| "let", | ||
| "loop", | ||
| "match", | ||
| "mod", | ||
| "move", | ||
| "mut", | ||
| "pub", | ||
| "ref", | ||
| "return", | ||
| "self", | ||
| "Self", | ||
| "static", | ||
| "struct", | ||
| "super", | ||
| "trait", | ||
| "true", | ||
| "type", | ||
| "unsafe", | ||
| "use", | ||
| "where", | ||
| "while", | ||
| "async", | ||
| "await", | ||
| "dyn", | ||
| "abstract", | ||
| "become", | ||
| "box", | ||
| "do", | ||
| "final", | ||
| "macro", | ||
| "override", | ||
| "priv", | ||
| "typeof", | ||
| "unsized", | ||
| "virtual", | ||
| "yield", | ||
| "try" | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * @param $type | ||
| * @return string | ||
| */ | ||
| public function getTypeName($type) | ||
| { | ||
| switch ($type) { | ||
| case self::TYPE_OBJECT: | ||
| return 'Option<HashMap<String, crate::client::ParamType>>'; | ||
| break; | ||
| case self::TYPE_INTEGER: | ||
| return 'i64'; | ||
| break; | ||
| case self::TYPE_STRING: | ||
| return '&str'; | ||
| break; | ||
| case self::TYPE_FILE: | ||
| return 'std::path::PathBuf'; | ||
| break; | ||
| case self::TYPE_BOOLEAN: | ||
| return 'bool'; | ||
| break; | ||
| case self::TYPE_ARRAY: | ||
| return '&[&str]'; | ||
| case self::TYPE_NUMBER: | ||
| return 'f64'; | ||
| break; | ||
| } | ||
|
|
||
| return $type; | ||
| } | ||
|
|
||
| /** | ||
| * @param array $param | ||
| * @return string | ||
| */ | ||
| public function getParamDefault(array $param) | ||
| { | ||
| return ""; | ||
| } | ||
|
|
||
| /** | ||
| * @param array $param | ||
| * @return string | ||
| */ | ||
| public function getParamExample(array $param) | ||
| { | ||
| $type = $param['type'] ?? ''; | ||
| $example = $param['example'] ?? ''; | ||
|
|
||
| $output = ''; | ||
|
|
||
| if(empty($example) && $example !== 0 && $example !== false) { | ||
| switch ($type) { | ||
| case self::TYPE_FILE: | ||
| $output .= 'std::path::PathBuf::from("./path-to-files/image.jpg")'; | ||
| break; | ||
| case self::TYPE_NUMBER: | ||
| case self::TYPE_INTEGER: | ||
| $output .= '0'; | ||
| break; | ||
| case self::TYPE_BOOLEAN: | ||
| $output .= 'false'; | ||
| break; | ||
| case self::TYPE_STRING: | ||
| $output .= 'String::new()'; | ||
| break; | ||
| case self::TYPE_OBJECT: | ||
| $output .= 'new Object()'; | ||
| break; | ||
| case self::TYPE_ARRAY: | ||
| $output .= '&[]'; | ||
| break; | ||
| } | ||
| } | ||
| else { | ||
| switch ($type) { | ||
| case self::TYPE_OBJECT: | ||
| case self::TYPE_FILE: | ||
| case self::TYPE_NUMBER: | ||
| case self::TYPE_INTEGER: | ||
| case self::TYPE_ARRAY: | ||
| $output .= $example; | ||
| break; | ||
| case self::TYPE_BOOLEAN: | ||
| $output .= ($example) ? 'true' : 'false'; | ||
| break; | ||
| case self::TYPE_STRING: | ||
| $output .= sprintf('"%s"', $example); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return $output; | ||
| } | ||
|
|
||
| /** | ||
| * @return array | ||
| */ | ||
| public function getFiles() | ||
| { | ||
| return [ | ||
| [ | ||
| 'scope' => 'default', | ||
| 'destination' => 'Cargo.toml', | ||
| 'template' => '/rust/Cargo.toml.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'default', | ||
| 'destination' => 'README.md', | ||
| 'template' => '/rust/README.md.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'default', | ||
| 'destination' => 'CHANGELOG.md', | ||
| 'template' => '/rust/CHANGELOG.md.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'default', | ||
| 'destination' => 'LICENSE', | ||
| 'template' => '/rust/LICENSE.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'method', | ||
| 'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md', | ||
| 'template' => '/rust/docs/example.md.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'method', | ||
| 'destination' => 'src/lib.rs', | ||
| 'template' => '/rust/src/lib.rs.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'method', | ||
| 'destination' => 'src/client.rs', | ||
| 'template' => '/rust/src/client.rs.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'method', | ||
| 'destination' => 'src/services/mod.rs', | ||
| 'template' => '/rust/src/services/mod.rs.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'method', | ||
| 'destination' => 'src/services/exception.rs', | ||
| 'template' => '/rust/src/services/exception.rs.twig', | ||
| 'minify' => false, | ||
| ], | ||
| [ | ||
| 'scope' => 'service', | ||
| 'destination' => 'src/services/{{service.name | caseDash}}.rs', | ||
| 'template' => '/rust/src/services/service.rs.twig', | ||
| 'minify' => false, | ||
| ], | ||
| ]; | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Generated by Cargo | ||
| # will have compiled files and executables | ||
| debug/ | ||
| target/ | ||
|
|
||
| # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
| # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
| Cargo.lock | ||
|
|
||
| # These are backup files generated by rustfmt | ||
| **/*.rs.bk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{sdk.changelog}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| [package] | ||
| name = "{{ language.params.packageName }}" | ||
| version = "{{ sdk.version }}" | ||
| authors = ["Appwrite Team <[email protected]>"] | ||
| edition = "2018" | ||
| description = "{{ sdk.shortDescription }}" | ||
| licence = "{{ sdk.licenseName }}" | ||
| repository = "{{ sdk.gitURL }}" | ||
|
|
||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
|
||
| [dependencies] | ||
| url = "2.2.1" | ||
| reqwest = { version = "0.11", features = ["json", "blocking", "multipart"] } | ||
|
|
||
| # Serde | ||
| serde = "1.0.124" | ||
| serde_derive = "1.0.124" | ||
| serde_json = "1.0.59" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{sdk.licenseContent}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.