{"id":23134431,"url":"https://github.com/wangwilly/rust-patent-protector","last_synced_at":"2025-04-04T08:20:57.888Z","repository":{"id":263645823,"uuid":"891017241","full_name":"WangWilly/rust-patent-protector","owner":"WangWilly","description":"Toy project to learn building web services with Rust.","archived":false,"fork":false,"pushed_at":"2024-11-24T19:45:18.000Z","size":612,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T19:24:31.740Z","etag":null,"topics":["axum","backend","db-migration","deployment","diesel-cli","diesel-rs","groq-integration","mvc-pattern","patent","rust","toy-project"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WangWilly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-19T15:26:50.000Z","updated_at":"2024-11-24T19:55:01.000Z","dependencies_parsed_at":"2024-11-19T17:43:39.234Z","dependency_job_id":"b0236183-4d0e-4aff-adef-27fa63514d3c","html_url":"https://github.com/WangWilly/rust-patent-protector","commit_stats":null,"previous_names":["wangwilly/rust-patent-protector"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangWilly%2Frust-patent-protector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangWilly%2Frust-patent-protector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangWilly%2Frust-patent-protector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangWilly%2Frust-patent-protector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WangWilly","download_url":"https://codeload.github.com/WangWilly/rust-patent-protector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142425,"owners_count":20890727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axum","backend","db-migration","deployment","diesel-cli","diesel-rs","groq-integration","mvc-pattern","patent","rust","toy-project"],"created_at":"2024-12-17T12:10:39.867Z","updated_at":"2025-04-04T08:20:57.856Z","avatar_url":"https://github.com/WangWilly.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-patent-protector\n\nToy project to learn Rust and Diesel.\n\n## Backend (Rust)\n\n### Setup\n\n```bash\n# Install Rust\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n\n# Install Diesel CLI\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/diesel-rs/diesel/releases/latest/download/diesel_cli-installer.sh | sh\n\n# Create database\ncd develop-gears\ndocker compose up -d\n\n# Database tables\ndiesel migration generate [migration-name]\n\n# Run migrations\n./scripts/migrate.sh\n```\n\n### Run\n\n```bash\n./scripts/serve-backend.sh dev\n```\n\n### Deploy\n\n```bash\n./scripts/build-migration.sh\n./scripts/build-backend.sh\n\ncd deployments\ndocker compose up -d\n```\n\nResources:\n- 🤔 https://www.reddit.com/r/rust/comments/16bswvl/looking_for_the_perfect_dockerfile_for_rust/\n- https://stackoverflow.com/questions/10319652/check-if-a-file-is-executable\n- https://www.shuttle.dev/blog/2024/01/09/getting-started-tracing-rust\n- ~~https://stackoverflow.com/questions/49098753/unable-to-run-a-docker-image-with-a-rust-executable~~\n- https://users.rust-lang.org/t/release-binary-not-working-in-docker/36383/4\n- ~~https://stackoverflow.com/questions/30780780/difference-between-stdout-and-dev-stdout~~\n- ~~https://stackoverflow.com/questions/74957107/how-to-conditionally-use-tracings-non-blocking-writer-instead-of-stdout~~\n\n### Misc\n\n- https://diesel.rs/guides/getting-started\n- https://www.reddit.com/r/rust/comments/16sj6af/diesel_table_scheme_migration/\n- https://github.com/diesel-rs/diesel/blob/master/guide_drafts/trait_derives.md\n- https://stackoverflow.com/questions/27589054/what-is-the-correct-way-to-use-lifetimes-with-a-struct-in-rust\n\n- https://stackoverflow.com/questions/77540941/rust-axum-router-sub-directories\n- https://docs.rs/axum/latest/axum/struct.Router.html#method.merge\n- https://medium.com/geekculture/dependency-injection-in-rust-3822bf689888\n\n- https://play.rust-lang.org/?version=stable\u0026mode=debug\u0026edition=2015\u0026gist=2794e5f6f7015cb3c018dca111cf732e\n\n- https://users.rust-lang.org/t/why-use-diesel-when-its-not-async/90160\n- https://users.rust-lang.org/t/rust-arrays-and-vectors/117607\n\n## Learning Rust\n\n- https://doc.rust-lang.org/cargo/guide/project-layout.html\n- https://doc.rust-lang.org/cargo/reference/manifest.html\n- https://github.com/janos-r/axum-template\n\n### To move or to borrow? That is the question\n\n- https://www.reddit.com/r/learnrust/comments/13gbrf4/to_move_or_to_borrow/\n- https://users.rust-lang.org/t/rationale-for-move-copy-borrow-syntax/87493\n\nWhy This Design? Rust’s Ownership Model\n\n```rust\nlet mut b1 = 1;\nlet b2 = \u0026mut b1;\nlet b3 = \u0026mut b1;  // Fail. Cannot mutably borrow when already mutably borrowed\nprintln!(\"{:?} {:?} {:?}\", b1, b2, b3);\n```\n1.\tFirst Mutable Borrow: The line `let b2 = \u0026mut b1;` creates a mutable reference to `b1`. At this point, `b1` is mutably borrowed by `b2`.\n2.\tSecond Mutable Borrow: The line `let b3 = \u0026mut b1;` attempts to create another mutable reference to `b1`. This violates Rust’s borrowing rules because `b1` is already mutably borrowed by `b2`. Rust does not allow multiple mutable borrows at the same time to prevent data races.\n3.\tBorrow Checker Error: The compiler throws an error because it detects that `b1` is being borrowed mutably more than once at the same time, which could lead to undefined behavior if allowed.\n\nRust’s design aims to prevent data races at compile time by enforcing these borrowing rules. Data races occur when two or more threads access shared data simultaneously, and at least one of the accesses is a write. By ensuring that only one mutable reference exists at any given time, Rust guarantees that no other part of the program can modify the data unexpectedly, thus maintaining memory safety and preventing data races.\nThis approach allows Rust to provide high performance and safety guarantees without needing a garbage collector, making it suitable for systems programming where both efficiency and reliability are critical.\n\n- https://www.openmymind.net/Rust-Ownership-Move-and-Borrow-part-1/\n\n### Why using macros?\n\nTo illustrate the necessity of using macros in Rust, let's consider a situation where you need to generate repetitive or boilerplate code. Macros provide a powerful way to automate this process, reducing errors and improving maintainability.\n\n[Read more](./docs/macro.md)\n\n### Lifetimes explaination\n\nLifetimes are a fundamental concept in Rust that help the compiler ensure memory safety without the need for a garbage collector. Understanding lifetimes is crucial for writing safe and efficient Rust code.\n\n[Read more](./docs/lifetime.md)\n\n### Logging in Rust\n\n- https://stackoverflow.com/questions/75009289/how-to-enable-logging-tracing-with-axum\n\n### Error Handling in Rust\n\nYou should use `core::result::Result` when you need to represent the outcome of an operation that can either succeed or fail. This type is particularly useful in functions that may encounter errors and need to propagate them to the caller.\n\n[Read more](./docs/error.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangwilly%2Frust-patent-protector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangwilly%2Frust-patent-protector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangwilly%2Frust-patent-protector/lists"}