ProjectTemplateService

Struct ProjectTemplateService 

Source
pub struct ProjectTemplateService { /* private fields */ }
Expand description

Service for generating project template files

§Examples

use mecha10_cli::services::ProjectTemplateService;

let service = ProjectTemplateService::new();

// Generate all project files
service.create_readme(&project_path, "my-robot").await?;
service.create_cargo_toml(&project_path, "my-robot", false).await?;

Implementations§

Source§

impl ProjectTemplateService

Source

pub fn new() -> Self

Create a new ProjectTemplateService

Source

pub async fn create_readme(&self, path: &Path, project_name: &str) -> Result<()>

Create README.md for the project

Source

pub async fn create_gitignore(&self, path: &Path) -> Result<()>

Create .gitignore for the project

Source

pub async fn create_cargo_config( &self, path: &Path, framework_path: &str, ) -> Result<()>

Create .cargo/config.toml for framework development

This patches all mecha10-* dependencies to use local paths instead of crates.io. Requires a framework_path pointing to the mecha10-monorepo root.

Source

pub async fn create_cargo_toml( &self, path: &Path, project_name: &str, dev: bool, ) -> Result<()>

Create Cargo.toml for the project

§Arguments
  • path - Project root path
  • project_name - Name of the project
  • dev - Whether this is for framework development (affects dependency resolution)
Source

pub async fn create_main_rs( &self, path: &Path, project_name: &str, ) -> Result<()>

Create src/main.rs for the project

Source

pub async fn create_build_rs(&self, path: &Path) -> Result<()>

Create build.rs for the project

This build script generates:

  1. node_registry.rs - Node dispatcher based on mecha10.json
  2. embedded.rs - Embedded asset accessors
Source

pub async fn create_embedded_structure(&self, path: &Path) -> Result<()>

Create embedded directory structure

Source

pub async fn create_env_example( &self, path: &Path, project_name: &str, framework_path: Option<String>, ) -> Result<()>

Create .env.example for the project

§Arguments
  • path - Project root path
  • project_name - Name of the project
  • framework_path - Optional framework path for development mode
Source

pub async fn create_rustfmt_toml(&self, path: &Path) -> Result<()>

Create rustfmt.toml for the project

Source

pub async fn create_docker_compose( &self, path: &Path, project_name: &str, ) -> Result<()>

Create docker-compose.yml for the project

Generates a Docker Compose file with Redis and optional PostgreSQL services for local development and deployment.

§Arguments
  • path - Project root path
  • project_name - Name of the project (used for container naming)
Source

pub async fn create_package_json( &self, path: &Path, project_name: &str, ) -> Result<()>

Create package.json for npm dependencies

Includes @mecha10/simulation-models and @mecha10/simulation-environments dependencies. Resolution happens at runtime via MECHA10_FRAMEWORK_PATH env var:

  • If set: Uses local monorepo packages
  • If not set: Uses node_modules/@mecha10/* (requires npm install)
§Arguments
  • path - Project root path
  • project_name - Name of the project
Source

pub async fn create_requirements_txt(&self, path: &Path) -> Result<()>

Create requirements.txt for Python dependencies

Includes Python packages needed for AI nodes (onnx, onnxruntime). Install with: mecha10 setup or pip install -r requirements.txt

§Arguments
  • path - Project root path
Source

pub async fn create_mecha10_json( &self, path: &Path, project_name: &str, template: &Option<String>, ) -> Result<()>

Create mecha10.json configuration file

Generates the main project configuration file with robot identity, simulation settings, nodes, services, and Docker configuration.

§Arguments
  • path - Project root directory
  • project_name - Name of the project
  • template - Robot template (rover, humanoid, etc.)
Source

pub async fn create_simulation_model_json(&self, path: &Path) -> Result<()>

Create simulation/models/model.json

Generates the rover robot physical model configuration for Godot simulation from embedded template.

§Arguments
  • path - Project root directory
Source

pub async fn create_simulation_environment_json( &self, path: &Path, ) -> Result<()>

Create simulation/environments/basic_arena/environment.json

Generates the basic arena environment configuration for Godot simulation from embedded template.

§Arguments
  • path - Project root directory
Source

pub async fn create_node_configs(&self, path: &Path) -> Result<()>

Create node configuration files from embedded configs

Writes node configs to configs/dev/nodes/{node}/config.json Configs are embedded from packages/nodes/*/configs/ at build time (single source of truth).

§Arguments
  • path - Project root directory
Source

pub async fn create_simulation_configs(&self, path: &Path) -> Result<()>

Create simulation config files from embedded configs

Writes simulation configs to configs/{env}/simulation/config.json. Configs are embedded from packages/simulation/configs/ at build time (single source of truth).

§Arguments
  • path - Project root directory
Source

pub async fn create_simulation_assets(&self, path: &Path) -> Result<()>

Create simulation image assets from embedded templates

Writes image assets to assets/images/ directory. This is used in standalone mode when framework path is not available. In framework dev mode, these are copied from the simulation package instead.

§Arguments
  • path - Project root directory
Source

pub async fn create_behavior_templates(&self, path: &Path) -> Result<()>

Create behavior tree templates from embedded files

Writes behavior tree JSON files to behaviors/ directory. This is used in standalone mode when framework path is not available. In framework dev mode, these are copied from behavior-runtime/seeds/ instead.

§Arguments
  • path - Project root directory
Source

pub async fn create_simulation_docker_files(&self, path: &Path) -> Result<()>

Create simulation Docker files from embedded templates

Writes Dockerfile, entrypoint.sh, and .dockerignore to simulation/ directory. This is used in standalone mode when framework path is not available. In framework dev mode, these are copied from packages/simulation/docker/ instead.

§Arguments
  • path - Project root directory

Trait Implementations§

Source§

impl Default for ProjectTemplateService

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more