oceanpkg/drop/kind/
exe.rs1use std::{
2 path::PathBuf,
3 process::Command,
4};
5use crate::{
6 drop::{
7 Metadata,
8 name::Query,
9 },
10 install::InstallTarget,
11};
12
13#[derive(Clone, Debug)]
15pub struct Exe {
16 metadata: Metadata,
17 bin_name: String,
18}
19
20impl Exe {
21 pub fn installed<S: AsRef<str>>(
23 query: &Query<S>,
24 target: &InstallTarget,
25 ) -> Result<Self, ()> {
26 let query = query.to_ref::<str>();
27 unimplemented!("TODO: Find installation of {:?} for {:?}", query, target)
28 }
29
30 #[inline]
32 pub const fn metadata(&self) -> &Metadata {
33 &self.metadata
34 }
35
36 #[inline]
38 pub fn bin_name(&self) -> &str {
39 &self.bin_name
40 }
41
42 pub fn bin_path<'t>(
44 &self,
45 target: &'t InstallTarget,
46 ) -> Result<PathBuf, FindError<'t>> {
47 unimplemented!(
48 "TODO: Find {:?} binary for {:?}",
49 self.metadata.name,
50 target,
51 )
52 }
53
54 pub fn command<'t>(
57 &self,
58 target: &'t InstallTarget
59 ) -> Result<Command, FindError<'t>> {
60 self.bin_path(target).map(Command::new)
61 }
62}
63
64#[derive(Debug)]
66pub struct FindError<'a> {
67 target: &'a InstallTarget,
68}