{"id":28092406,"url":"https://github.com/itsethra/scotch","last_synced_at":"2025-07-10T19:03:54.150Z","repository":{"id":65506008,"uuid":"589678495","full_name":"ItsEthra/scotch","owner":"ItsEthra","description":"Create WASM plugins easily in Rust","archived":false,"fork":false,"pushed_at":"2023-01-26T13:58:48.000Z","size":202,"stargazers_count":66,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-16T22:23:44.175Z","etag":null,"topics":["plugin","plugin-system","rust","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","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/ItsEthra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-16T17:19:13.000Z","updated_at":"2025-06-03T06:24:21.000Z","dependencies_parsed_at":"2023-02-14T18:01:00.284Z","dependency_job_id":null,"html_url":"https://github.com/ItsEthra/scotch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ItsEthra/scotch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsEthra%2Fscotch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsEthra%2Fscotch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsEthra%2Fscotch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsEthra%2Fscotch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ItsEthra","download_url":"https://codeload.github.com/ItsEthra/scotch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ItsEthra%2Fscotch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264638122,"owners_count":23642112,"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":["plugin","plugin-system","rust","wasm","webassembly"],"created_at":"2025-05-13T13:12:15.579Z","updated_at":"2025-07-10T19:03:54.136Z","avatar_url":"https://github.com/ItsEthra.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scotch\nLibrary for creating WASM plugins with Rust.\nScotch allows you to pass complex types to/from functions in WASM plugins.\nIt achieves that by encoding and decoding complex types when passed between host and guest environment.\nEncoding and decoding is handled by `bincode@2.0.0-rc.2` so you need your types\nto implement `bincode::Encode` and `bincode::Decode` traits.\n\n## Headless mode\nYou can disable default features to enable headless mode. This should reduce host binary size.\nIn headless mode you are unable to compile wasm bytecode and need to rely on serialized plugins.\nSee `WasmPluginBuilder::from_serialized`, `WasmPluginBuilder::from_serialized_compressed`, \n`WasmPlugin::serialize`, `WasmPlugin::serialize_compress`. `*_compress`, `*_compressed` functions\nuses `flate2` crate to compress/decompress plugins, to use them you need to have `flate2` feature enabled.\n\n## Instalation\n```toml\n# In your main application\n[dependenices]\nscotch-host = \"0.1\"\n\n# In your plugins\n[dependencies]\nscotch-guest = \"0.1\"\n```\n\n## Example application\n```rust\n// Define functions that your plugin exports.\n#[scotch_host::guest_functions]\nextern \"C\" {\n    // To pass complex types you use references to them, not owned types.\n    // The name must match with the name of the plugin function.\n    pub fn add_up_list(nums: \u0026Vec\u003ci32\u003e) -\u003e i32;\n}\n\n// Create your plugin\nlet plugin = WasmPlugin::builder()\n    .with_state(0)\n    // PLUGIN_BYTES is a slice of your wasm plugin.\n    .from_binary(PLUGIN_BYTES)?\n    // This call caches exports of your plugin.\n    .with_exports(make_exports![add_up_list])\n    .finish()?;\n\n// Call the function\nlet sum = plugin.function_unwrap::\u003cadd_up_list\u003e()(\u0026vec![1, 2, 3, 4, 5])?;\nassert_eq!(sum, 15);\n```\n\n## Example plugin\n```rust\n// This is required.\nscotch_guest::export_alloc!();\n\n// Functions marked with `guest_function` will be exposed to the host.\n// All complex types such as Vec, String, user-defined types must be passed by immutable reference.\n#[scotch_guest::guest_function]\nfn add_up_list(items: \u0026Vec\u003ci32\u003e) -\u003e i32 {\n    items.iter().sum::\u003ci32\u003e()\n}\n```\n\nMore complete example can be found [here](/examples)\n\n## Planned features\n* [ ] Improve codegeneration with proc macros.\n* [ ] Mutable references.\n* [ ] WASI support.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsethra%2Fscotch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsethra%2Fscotch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsethra%2Fscotch/lists"}