1"use strict";(self.webpackChunkfarm_docs=self.webpackChunkfarm_docs||[]).push([[5249],{55012:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>o,contentTitle:()=>c,default:()=>d,frontMatter:()=>n,metadata:()=>p,toc:()=>s});var a=t(49214),i=t(36906);const n={},c="Rust Api",p={id:"api/rust-api",title:"Rust Api",description:"You can create a Farm Rust compiler in your rust code. Example:",source:"@site/docs/api/rust-api.md",sourceDirName:"api",slug:"/api/rust-api",permalink:"/docs/api/rust-api",draft:!1,unlisted:!1,editUrl:"https://github.com/farm-fe/farm-fe.github.io/tree/main/docs/api/rust-api.md",tags:[],version:"current",frontMatter:{},sidebar:"apiSidebar",previous:{title:"Javascript Api",permalink:"/docs/api/javascript-api"}},o={},s=[];function l(e){const r={a:"a",code:"code",h1:"h1",header:"header",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.header,{children:(0,a.jsx)(r.h1,{id:"rust-api",children:"Rust Api"})}),"\n",(0,a.jsx)(r.p,{children:"You can create a Farm Rust compiler in your rust code. Example:"}),"\n",(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-rust",children:'use farmfe_compiler::Compiler;\nuse farmfe_core::config::Config;\n\n// create farm compiler\npub fn create_farm_compiler() {\n let config = Config::default();\n let extra_plugins = vec![];\n\n let compiler = Compiler::new(config, extra_plugins);\n\n compiler\n}\n\n// compile the project\npub fn compile() {\n let compiler = create_farm_compiler();\n compiler.compile()\n}\n\n// perform hot update\npub fn update(compiler: Compiler) {\n let update_result = compiler.update(vec![(String::from("/root/index.ts"), UpdateType:Update)], || {\n // called when all update(including resource regeneration) finished\n }, true);\n\n // handle update_result...\n}\n'})}),"\n",(0,a.jsxs)(r.p,{children:["Farm Rust compiler is exported by ",(0,a.jsx)(r.a,{href:"https://docs.rs/farmfe_core/latest/farmfe_compiler",children:(0,a.jsx)(r.code,{children:"farmfe_compiler"})})," crate. Refer to ",(0,a.jsx)(r.a,{href:"https://docs.rs/farmfe_core/latest/farmfe_compiler",children:(0,a.jsx)(r.code,{children:"farmfe_compiler"})})," documentation."]})]})}function d(e={}){const{wrapper:r}={...(0,i.R)(),...e.components};return r?(0,a.jsx)(r,{...e,children:(0,a.jsx)(l,{...e})}):l(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.