ProjectService

Struct ProjectService 

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

Project service for project management operations

§Examples

use mecha10_cli::services::ProjectService;
use std::path::Path;

// Detect project from current directory
let project = ProjectService::detect(Path::new("."))?;
println!("Project: {}", project.name()?);

// Validate project structure
project.validate()?;

// List all nodes
let nodes = project.list_nodes()?;

Implementations§

Source§

impl ProjectService

Source

pub fn detect(path: &Path) -> Result<Self>

Detect a Mecha10 project from a given path

Searches upward from the given path to find a mecha10.json file.

§Arguments
  • path - Starting path to search from
§Errors

Returns an error if no mecha10.json is found in the path or any parent directory.

Source

pub fn new(path: PathBuf) -> Self

Create a new project at the given path

This does not generate the project structure, it just creates a ProjectService instance for a path where a project will be created. Use the init handler to actually create project files.

§Arguments
  • path - Path where the project will be created
Source

pub fn root(&self) -> &Path

Get the project root directory

Source

pub fn config_path(&self) -> PathBuf

Get the path to mecha10.json

Source

pub fn is_initialized(&self) -> bool

Check if a mecha10.json exists at the project root

Source

pub fn name(&self) -> Result<String>

Get project name from metadata

Tries mecha10.json first, then falls back to Cargo.toml

Source

pub fn version(&self) -> Result<String>

Get project version from metadata

Tries mecha10.json first, then falls back to Cargo.toml

Source

pub fn load_metadata(&self) -> Result<(String, String)>

Load project metadata (name and version)

Tries mecha10.json first, then falls back to Cargo.toml

Source

pub fn validate(&self) -> Result<()>

Validate project structure

Checks that required directories and files exist.

Source

pub fn list_nodes(&self) -> Result<Vec<String>>

List all nodes in the project

Returns a list of node names found in the nodes/ directory.

Source

pub fn list_drivers(&self) -> Result<Vec<String>>

List all drivers in the project

Returns a list of driver names found in the drivers/ directory.

Source

pub fn list_types(&self) -> Result<Vec<String>>

List all custom types in the project

Returns a list of type names found in the types/ directory.

Source

pub async fn list_enabled_nodes(&self) -> Result<Vec<String>>

List all enabled nodes from configuration

Loads the project config and returns enabled nodes.

Source

pub fn path(&self, relative: &str) -> PathBuf

Get a path relative to the project root

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

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
Source§

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

Source§

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
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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