{"id":25972024,"url":"https://github.com/mattyhall/rs-tiled","last_synced_at":"2025-03-05T00:02:46.998Z","repository":{"id":21585930,"uuid":"24905956","full_name":"mapeditor/rs-tiled","owner":"mapeditor","description":"Reads files from the Tiled editor into Rust ","archived":false,"fork":false,"pushed_at":"2024-08-21T08:31:13.000Z","size":451,"stargazers_count":259,"open_issues_count":16,"forks_count":100,"subscribers_count":6,"default_branch":"current","last_synced_at":"2024-08-29T00:02:41.970Z","etag":null,"topics":["gamedev","rust","tiled"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/tiled","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapeditor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2014-10-07T18:46:38.000Z","updated_at":"2024-08-22T09:08:02.000Z","dependencies_parsed_at":"2024-05-01T07:48:58.849Z","dependency_job_id":"23baee1e-7355-4c38-a632-522a95ccb529","html_url":"https://github.com/mapeditor/rs-tiled","commit_stats":{"total_commits":277,"total_committers":52,"mean_commits":5.326923076923077,"dds":0.6570397111913358,"last_synced_commit":"c8ac751ee01aee74011c624484baae727a667123"},"previous_names":["mattyhall/rs-tiled"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapeditor%2Frs-tiled","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapeditor%2Frs-tiled/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapeditor%2Frs-tiled/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapeditor%2Frs-tiled/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapeditor","download_url":"https://codeload.github.com/mapeditor/rs-tiled/tar.gz/refs/heads/current","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940573,"owners_count":20045881,"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":["gamedev","rust","tiled"],"created_at":"2025-03-05T00:02:46.440Z","updated_at":"2025-03-05T00:02:46.986Z","avatar_url":"https://github.com/mapeditor.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# rs-tiled\n```toml\ntiled = \"0.13.0\"\n```\n\n[![Rust](https://github.com/mapeditor/rs-tiled/actions/workflows/rust.yml/badge.svg)](https://github.com/mapeditor/rs-tiled/actions/workflows/rust.yml)\n[![Crates.io](https://img.shields.io/crates/v/tiled.svg)](https://crates.io/crates/tiled)\n[![Docs Status](https://docs.rs/tiled/badge.svg)](https://docs.rs/tiled)\n[![dependency status](https://deps.rs/crate/tiled/latest/status.svg)](https://deps.rs/crate/tiled)\n\nA crate for reading TMX (map) and TSX (tileset) files from the [Tiled Map Editor](http://www.mapeditor.org/) into Rust.\nIt provides a huge set of features as well as a strong wrapper over internal features such as GIDs.\n\nDocumentation is available [on docs.rs](https://docs.rs/tiled/).\n\nCode contributions are welcome as are bug reports, documentation, suggestions and criticism.\n\nThe minimum supported TMX version is 0.13.\n\n## Example\n\n```rust\nuse tiled::Loader;\n\nfn main() {\n    let mut loader = Loader::new();\n    let map = loader.load_tmx_map(\"assets/tiled_base64_external.tmx\").unwrap();\n    println!(\"{:?}\", map);\n    println!(\"{:?}\", map.tilesets()[0].get_tile(0).unwrap().probability);\n    \n    let tileset = loader.load_tsx_tileset(\"assets/tilesheet.tsx\").unwrap();\n    assert_eq!(*map.tilesets()[0], tileset);\n}\n\n```\n\n## FAQ\n### How do I embed a map into my executable? / How do I read a file from anywhere else that isn't the filesystem's OS?\nThe crate does all of its reading through the `read_from` function of the [`ResourceReader`](https://docs.rs/tiled/latest/tiled/trait.ResourceReader.html) that you create the loader with. By default, this reader is set to [`FilesystemResourceReader`](https://docs.rs/tiled/latest/tiled/struct.FilesystemResourceReader.html) and all files are read through the OS's filesystem. You can however change this.\n\nHere's an example mostly taken from `Loader::with_reader`'s documentation:\n```rust\nuse tiled::{DefaultResourceCache, Loader};\n\nlet mut loader = Loader::with_reader(\n    // Specify the reader to use. We can use anything that implements `ResourceReader`, e.g. FilesystemResourceReader.\n    // Any function that has the same signature as `ResourceReader::read_from` also implements it.\n    // Here we define a reader that embeds the map at \"assets/tiled_xml.csv\" into the executable, and allow\n    // accessing it only through \"/my-map.tmx\"\n    // ALL maps, tilesets and templates will be read through this function, even if you don't explicitly load them\n    // (They can be dependencies of one you did want to load in the first place).\n    // Doing this embedding is useful for places where the OS filesystem is not available (e.g. WASM applications).\n    |path: \u0026std::path::Path| -\u003e std::io::Result\u003c_\u003e {\n        if path == std::path::Path::new(\"/my-map.tmx\") {\n            Ok(std::io::Cursor::new(include_bytes!(\"../assets/tiled_csv.tmx\")))\n        } else {\n            Err(std::io::ErrorKind::NotFound.into())\n        }\n    }\n);\n```\nIf the closure approach confuses you or you need more flexibility, you can always implement [`ResourceReader`](https://docs.rs/tiled/latest/tiled/trait.ResourceReader.html) on your own structure.\n\n### How do I get the crate to work on WASM targets?\nThe crate supports WASM, but since it does not currently support asynchronous loading, there are some gotchas.\n\n- First, to make it work on any WASM target, **enable the wasm feature**, like so:\n```toml\n[dependencies]\n# ...\ntiled = { version = \".....\", features = [\"wasm\"] }\n```\n\n- Second, since you cannot use the filesystem as normally on the web, you cannot use `FilesystemResourceReader`. As such,\nyou'll need to implement your own `ResourceReader`. This is a pretty simple task, as you just need to return anything\nthat is `Read`able when given a path, e.g.:\n```rust\nuse std::io::Cursor;\n\nstruct MyReader;\n\nimpl tiled::ResourceReader for MyReader {\n    type Resource = Cursor\u003c\u0026'static [u8]\u003e;\n    type Error = std::io::Error;\n\n    // really dumb example implementation that just keeps resources in memory\n    fn read_from(\u0026mut self, path: \u0026std::path::Path) -\u003e std::result::Result\u003cSelf::Resource, Self::Error\u003e {\n        if path == std::path::Path::new(\"my_map.tmx\") {\n            Ok(Cursor::new(include_bytes!(\"../assets/tiled_xml.tmx\")))\n        } else {\n            Err(std::io::Error::new(std::io::ErrorKind::NotFound, \"file not found\"))\n        }\n    }\n}\n```\nYou can also use a function with the same signature as `tiled::ResourceReader::read_from`; check the\n`ResourceReader` docs for more information.\n\n### Licences\n\nassets/tilesheet.png by [Buch](https://opengameart.org/content/sci-fi-interior-tiles)\n\nLicenced under MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattyhall%2Frs-tiled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattyhall%2Frs-tiled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattyhall%2Frs-tiled/lists"}