{"id":30754958,"url":"https://github.com/OrangeTux/rauts","last_synced_at":"2025-09-04T10:03:36.431Z","repository":{"id":74376079,"uuid":"538057053","full_name":"OrangeTux/rauts","owner":"OrangeTux","description":"A Rust project exploring a routing mechanis for OCPP (Open Charge Point Protocol).","archived":false,"fork":true,"pushed_at":"2023-01-04T08:45:50.000Z","size":54,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-31T14:52:54.996Z","etag":null,"topics":["ocpp"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Roger/rauts","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OrangeTux.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}},"created_at":"2022-09-18T09:17:21.000Z","updated_at":"2023-08-30T10:06:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"7db725bb-0325-4a79-bfd8-4cb4f06c5e4f","html_url":"https://github.com/OrangeTux/rauts","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.4,"last_synced_commit":"845cb647bb13f4d6cdce802cb323976a80499c79"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OrangeTux/rauts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeTux%2Frauts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeTux%2Frauts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeTux%2Frauts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeTux%2Frauts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OrangeTux","download_url":"https://codeload.github.com/OrangeTux/rauts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeTux%2Frauts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273588865,"owners_count":25132857,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ocpp"],"created_at":"2025-09-04T10:01:20.306Z","updated_at":"2025-09-04T10:03:36.421Z","avatar_url":"https://github.com/OrangeTux.png","language":"Rust","funding_links":[],"categories":["Tools and Resources"],"sub_categories":["OCPP"],"readme":"# Rauts\nRauts is library for building [Open Charge Point Protocol][OCPP] (OCPP) servers\nand clients. OCPP is de facto communication standard between chargers of electric vehicles (EV) and the servers\nmanaging the chargers.\n\nThe project is in very early stage. Currently, the focus is on designing a satisfying API for routing\nrequests and responses.\n\n## Quickstart\n\nClone the repository and run one of the [examples](examples/):\n\n```bash\n$ git clone https://github.com/OrangeTux/rauts.git\n$ cd rauts\n$ cargo run --example handler_func_with_multiple_arguments\n```\n\n## Handlers\n\nThe project is heavily inspired by \"magic handler functions\" as implemented in\n[Axum](https://docs.rs/axum/latest/axum/#handlers) and other projects.\n\nA regular function automatically implements the `Handler` trait when:\n1) It receives zero or more arguments. All arguments must implement `rauts::extract::FromRequest`.\n2) It must return something that implements `rauts::response::IntoResponse`\n\n### Arguments\n\nThese are valid examples of handler functions:\n\n```rust\nuse rauts::ocpp::v16::{\n    call::{Authorize, Call, Payload},\n    call_result,\n    call_result::{IdTagInfo, Status},\n    Action,\n};\n\n/// This `Handler` doesn't receive any arguments.\nfn heartbeat() -\u003e call_result::Heartbeat {\n    call_result::Heartbeat {\n        current_time: Utc::now(),\n    }\n}\n\n/// This `Handler` has one argument of type `Request`.\nfn authorize(request: Request) -\u003e call_result::Authorize {\n    let status = match request.call.payload {\n        Payload::Authorize(payload) =\u003e {\n            if payload.id_tag.as_str() == \"454564564\" {\n                Status::Accepted\n            } else {\n                Status::Invalid\n            }\n        }\n        _ =\u003e Status::Invalid,\n    };\n    call_result::Authorize {\n        id_tag_info: IdTagInfo {\n            status,\n            parent_id_tag: None,\n            expiry_date: None,\n        },\n    }\n}\n\n/// This `Handler` receives two arguments. Types of both arguments implement `rauts::extract::FromRequest`.\nfn also_authorize(\n    Authorize { id_tag }: Authorize,\n    ChargerId(charger_id): ChargerId,\n) -\u003e call_result::Authorize {\n    let status = match (id_tag.as_str(), charger_id.as_str()) {\n        (\"424242\", \"Alfen 123\") =\u003e Status::Accepted,\n        _ =\u003e Status::Invalid,\n    };\n    call_result::Authorize {\n        id_tag_info: IdTagInfo {\n            status,\n            parent_id_tag: None,\n            expiry_date: None,\n        },\n    }\n}\n```\n\n## Router\n\n`Handler`s are registered at a `Router`. The `Router` is responsible for calling the correct `Handler` when the `Router` receives a `Request`.\n\n```rust\nuse rauts::extract::{ChargerId, Request}\nuse rauts::handler::IntoHandler;\nuse rauts::Router;\nuse rauts::ocpp::v16::{\n   call::{Call, Heartbeat},\n   Action\n}\n\nlet router: Router\u003cAction\u003e =\n   Router::new()\n      .register(heartbeat.into_handler(), Action::Heartbeat)\n      .register(authorize.into_handler(), Action::Authorize);\n\nlet call: Call = Heartbeat {}.into();\nlet request = Request {\n    call,\n    charger_id: ChargerId(\"Alfen 123\".to_string()),\n};\n\nrouter.route(\u0026request).unwrap();\n```\n\n## Further reading\n* [Magical handler functions in Rust - Bernard Kolobara](https://lunatic.solutions/blog/magic-handler-functions-in-rust/)\n* [Rust's Axum style magic functions example -  Alex Puschinsky](https://github.com/alexpusch/rust-magic-function-params)\n* [A Reddit thread discussing the previous post](https://www.reddit.com/r/rust/comments/xornz5/axums_magical_handler_methods_amazed_me_when_i/)\n\n[Open Charge Point Protocol]: https://en.wikipedia.org/wiki/Open_Charge_Point_Protocol\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOrangeTux%2Frauts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOrangeTux%2Frauts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOrangeTux%2Frauts/lists"}