pub struct RuntimeDetector { /* private fields */ }Expand description
Finds the runtime of a project: the first option, in the order they were
added, that matches an input the way the Strategy says.
PHP: Utopia\Detector\Detector\Runtime.
use utopia_detector::{Node, Php, RuntimeDetector, Strategy};
let mut detector = RuntimeDetector::new(Strategy::Extension, "yarn");
detector.add_option(Php).add_option(Node);
detector.add_input("src/main.ts").add_input("Dockerfile");
let runtime = detector.detect().expect("a runtime");
assert_eq!(runtime.name(), "node");
assert_eq!(runtime.commands(), "yarn install");use Utopia\Detector\Detection\Runtime\Node;
use Utopia\Detector\Detection\Runtime\PHP;
use Utopia\Detector\Detector\Runtime;
use Utopia\Detector\Detector\Strategy;
$detector = new Runtime(new Strategy(Strategy::EXTENSION), 'yarn');
$detector->addOption(new PHP())->addOption(new Node());
$detector->addInput('src/main.ts')->addInput('Dockerfile');
$runtime = $detector->detect();
echo $runtime->getName(), "\n"; // node
echo $runtime->getCommands(), "\n"; // yarn installImplementations§
Source§impl RuntimeDetector
impl RuntimeDetector
Sourcepub fn new(strategy: Strategy, packager: impl Into<String>) -> Self
pub fn new(strategy: Strategy, packager: impl Into<String>) -> Self
A detector matching inputs by strategy, for a project using
packager (pnpm when unsure).
PHP: new Runtime($strategy, $packager).
Sourcepub fn add_option(&mut self, option: impl Runtime + 'static) -> &mut Self
pub fn add_option(&mut self, option: impl Runtime + 'static) -> &mut Self
Adds a runtime, tried after the others.
PHP: addOption($runtime).
Sourcepub fn add_input(&mut self, input: impl Into<String>) -> &mut Self
pub fn add_input(&mut self, input: impl Into<String>) -> &mut Self
Adds an input: a file name, or a language name for
Strategy::Languages.
PHP: addInput($content).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RuntimeDetector
impl !UnwindSafe for RuntimeDetector
impl Forget for RuntimeDetector
impl Freeze for RuntimeDetector
impl Move for RuntimeDetector
impl Send for RuntimeDetector
impl Sync for RuntimeDetector
impl Unpin for RuntimeDetector
impl UnsafeUnpin for RuntimeDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more