{"id":24433294,"url":"https://github.com/younisshah/nazar","last_synced_at":"2025-04-12T14:42:11.338Z","repository":{"id":57643678,"uuid":"97701932","full_name":"younisshah/nazar","owner":"younisshah","description":"A Tile38 client in rust!","archived":false,"fork":false,"pushed_at":"2017-08-09T11:34:25.000Z","size":19,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T09:12:32.638Z","etag":null,"topics":["redis","tile38"],"latest_commit_sha":null,"homepage":null,"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/younisshah.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}},"created_at":"2017-07-19T10:04:12.000Z","updated_at":"2025-03-15T10:16:16.000Z","dependencies_parsed_at":"2022-08-27T22:53:55.355Z","dependency_job_id":null,"html_url":"https://github.com/younisshah/nazar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younisshah%2Fnazar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younisshah%2Fnazar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younisshah%2Fnazar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younisshah%2Fnazar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/younisshah","download_url":"https://codeload.github.com/younisshah/nazar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248583073,"owners_count":21128511,"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":["redis","tile38"],"created_at":"2025-01-20T16:34:20.262Z","updated_at":"2025-04-12T14:42:11.304Z","avatar_url":"https://github.com/younisshah.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Nazar\n\n[![nazar](https://img.shields.io/crates/v/nazar.svg)](https://crates.io/crates/nazar)\n\n[Tile38](http://tile38.com) is an open source (MIT licensed), in-memory geolocation data store, spatial index, \nand realtime geofence. It supports a variety of object types including lat/lon points, bounding boxes, XYZ tiles, \nGeohashes, and GeoJSON.\n\n**nazar** is a Tile38 client in rust!\n\nThe API is a bit sane now albeit still weird and unstable. \n\n**API will change a lot**\n\n\n### Install\n\nIn your `Cargo.toml` file add under `[dependencies]` section\n\n\n```ini\n[dependencies]\nnazar = \"1.0.7\"\n```\n\n### Usage \n\n\n1) `SET` command\n\n```rust\nuse self::nazar::t38::Types::{String, Float};\nlet n = nazar::t38::Client::from(\"redis://127.0.0.1:9851\");\n\nmatch n.execute(\"SET\", vec![String(\"my\"), String(\"home\"), String(\"POINT\"), Float(23.12), Float(45.343)]) {\n    Ok(s) =\u003e println!(\"{}\", s),\n    Err(e) =\u003e panic!(e)\n}\n\n```\n\n2) `GET` command\n\n```rust\nuse self::nazar::t38::Types::{String};\nlet n = nazar::t38::Client::from(\"redis://127.0.0.1:9851\");\n\nmatch n.execute(\"GET\", vec![String(\"my\"), String(\"home\")]) {\n    Ok(s) =\u003e println!(\"{}\", s),\n    Err(e) =\u003e panic!(e)\n}\n```\n\n3) New API to execute T38 command - `cmd`, `arg` and `execute_with_args`. \nThis is a high-level API to execute Tile38 commands!\n\n```rust\nlet mut n = nazar::t38::Client::from(\"redis://127.0.0.1:9851\");\nn.cmd(\"SET\").arg(\"drivers\").arg(\"qwerty\").arg(\"POINT\").arg(\"23.54\").arg(\"32.74\");\nmatch n.execute_with_args() {\n    Ok(r) =\u003e println!(\"Result {}\", r),\n    Err(e) =\u003e panic!(e),\n};\n```\n\n4) `PING` to check if the server is live or dead.\n```rust\nuse nazar::t38::{Client};\nlet is_live = Client::ping(\"redis://127.0.0.1:9851\");\n```\n\n## Geofence features\n\nTo open a fence **only**, it is advisable to use `new` associated method like this:\n \n```rust\nlet n = nazar::t38::Client::new();\n```\n\nThen use `n` to open a geofence like this:\n\n1) Open a static `FENCE` using `open_fence`:\n\n```rust\nlet work = |msg| {\n    println!(\"FENCE updates {:?}\", msg);\n};\nn.open_fence(\"ws://127.0.0.1:9851\", \"my_fleet\", \"12.12\", \"33.22\", \"6000\", work);\n```\n\n2) Open a static geofence with GeoJSON object type. `open_fence_within`\n \n ```rust\nlet work = |msg| {\n    println!(\"FENCE updates {:?}\", msg);\n};\nn.open_fence_within(\"ws://localhost:9851\", \"my_fleet\", \"qwerty123\", vec![vec![12.32, 23.4], vec![22.32, 33.4], vec![42.32, 23.5], vec![12.32, 23.4]], work)\n```\n\n\n3) Open a static `FENCE` using `open_fence` (use this when to want to communicate with the server as well):\n\n```rust\nfn action (out: \u0026nazar::t38::NazarSender, msg: String) {\n    out.send(\"OK\").unwrap();\n    println!(\"{}\", msg);\n    // do stuff with msg\n}\n\n//.....\n\nn.open_fence2(\"ws://127.0.0.1:9851\", \"my_fleet\", \"12.12\", \"33.22\", \"6000\", action);\n```\n\n4) Open a static geofence with GeoJSON object type. `open_fence_within` (use this when you want to communicate with the server as well):\n \n ```rust\nfn action (out: \u0026nazar::t38::NazarSender, msg: String) {\n    out.send(\"OK\").unwrap();\n    println!(\"{}\", msg);\n    // do stuff with msg\n}\n\n//.....\n\nn.open_fence_within2(\"ws://localhost:9851\", \"my_fleet\", \"qwerty123\", vec![vec![12.32, 23.4], vec![22.32, 33.4], vec![42.32, 23.5], vec![12.32, 23.4]], action);\n```\n\n5) Open a static geofence (circular) using `open_fence_and_send` (use this when you want to send updates to the client who opened the fence)\n```rust\n n.open_fence_and_send(\"ws://127.0.0.1:9851\", \"my_fleet\", \"12.12\", \"33.22\", \"6000\", client); // client is a NazarSender\n```\n\n6) Open a static geofence (polygonal) using `open_fence_within_and_send` (use this when you want to send updates to the client who opened the fence)\n```rust\n n.open_fence_within_and_send(\"ws://localhost:9851\", \"my_fleet\", \"qwerty123\", vec![vec![12.32, 23.4], vec![22.32, 33.4], vec![42.32, 23.5], vec![12.32, 23.4]], client); // client is a NazarSender\n```\n\n\n####  A work in progress\n\nTODO\n\n1) Make sane API.\n1) Documentation\n2) Roaming `FENCE` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounisshah%2Fnazar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyounisshah%2Fnazar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounisshah%2Fnazar/lists"}