@fnet/to-rust
v0.1.10
Published
## Introduction
Downloads
178
Readme
@fnet/to-rust
Introduction
The @fnet/to-rust
project is designed to facilitate the process of building Rust applications using Flownet. It provides a framework to compile and package a Rust application efficiently, focusing on streamlining the building process while organizing necessary files and directories.
How It Works
This project operates by preparing and structuring a given Rust application source and its dependencies into a designated directory structure. It copies essential files and directories, utilizes specified templates, and builds the Rust application using Cargo. The entire process is automated to require minimal user intervention once parameters are set.
Key Features
- Directory Management: Automatically organizes necessary files and directories for Rust builds.
- Template Rendering: Utilizes template directories for consistent output structure.
- Automated Building: Executes
cargo build
commands to compile the application for both development and release modes. - Configurable Parameters: Allows customization of project details such as name, version, author, and more through parameters.
Conclusion
The @fnet/to-rust
project provides users with a straightforward method to compile and package Rust applications with an emphasis on organization and automation. It is a useful tool for developers looking to streamline their Rust application build process while maintaining a structured directory setup.
@fnet/to-rust Developer Guide
Overview
The @fnet/to-rust
library facilitates the setup and management of a Rust-based application framework. It focuses on preparing project directories, managing source and destination files, and building your Rust applications. By using @fnet/to-rust
, developers can streamline their build process, ensure consistent project structure, and automate the building of Rust applications with ease.
Installation
To install the @fnet/to-rust
library, use either of the following commands with npm or yarn:
npm install @fnet/to-rust
or
yarn add @fnet/to-rust
Usage
To use this library, you will typically call the main exported function within your JavaScript or TypeScript files. Below is a basic utilization pattern, where you define configuration parameters to prepare your Rust project build environment and handle generated assets.
Here is how you can make use of the @fnet/to-rust
:
import toRust from '@fnet/to-rust';
const config = {
params: {
name: "myRustApp",
entry: "src/esm",
version: "1.0.0",
title: "My Rust Application",
author: "Your Name",
description: "A simple Rust application built with Flownet",
vendor: "Your Organization",
package_dir: "./build/package",
out_dir: "./build/output"
},
src: "/path/to/source",
dest: "/path/to/destination"
};
toRust(config).then(() => {
console.log('Rust application build setup complete.');
}).catch((error) => {
console.error('Failed to prepare Rust application:', error);
});
Examples
Below is a concise example demonstrating the core functionality of @fnet/to-rust
:
Basic Setup
import toRust from '@fnet/to-rust';
const config = {
params: {
name: "rustProject",
entry: "src/rust_code",
package_dir: "./build/package",
out_dir: "./compiled/output"
},
src: "./source",
dest: "./destination"
};
(async () => {
try {
await toRust({
params: config.params,
src: config.src,
dest: config.dest
});
console.log('Setup successful!');
} catch (error) {
console.error('Error setting up project:', error);
}
})();
In this example, the toRust
function initializes and prepares the necessary directories and builds the Rust application as specified by the configuration params
. Ensure that your source and destination paths exist and are valid.
Acknowledgment
The @fnet/to-rust
library builds upon the capabilities of the Rust compiler and the Node.js ecosystem to streamline the Rust development process. Special thanks to all contributors who maintain the library and ensure its seamless integration into diverse development environments.
Input Schema
$type: object
$schema: https://json-schema.org/draft/2020-12/schema
properties:
params:
type: object
properties:
name:
type: string
description: The name of the project
default: rust
entry:
type: string
description: Entry directory for the app
default: app/esm
version:
type: string
description: Version of the project
default: 0.1.0
title:
type: string
description: Title of the project
default: Rust App
package_name:
type: string
description: Package name of the project
default: Same as name property
author:
type: string
description: Author of the project
default: Flownet
description:
type: string
description: Description of the project
default: Rust App built with Flownet
vendor:
type: string
description: Vendor of the project
default: flownet.ai
include_css:
type: boolean
description: Whether to include CSS
default: false
bundle_name:
type: string
description: Bundle name of the project
default: null
package_dir:
type: string
description: Directory for the package
default: ./.package/{params.name}
out_dir:
type: string
description: Output directory for the build
default: ./.out/{params.name}
required: []
config:
type: object
description: Configuration for the build process
src:
type: string
description: Source directory path
dest:
type: string
description: Destination directory path
required:
- params
- src
- dest