32 lines
862 B
Rust
32 lines
862 B
Rust
|
use super::typedef::{InternalTypeDef, TypeDef};
|
||
|
|
||
|
use super::GlobalNamespace;
|
||
|
|
||
|
#[derive(Clone, Copy)]
|
||
|
pub struct Command<'a> {
|
||
|
pub(super) id: usize,
|
||
|
pub(super) namespace: &'a GlobalNamespace,
|
||
|
}
|
||
|
|
||
|
impl<'a> Command<'a> {
|
||
|
pub fn get_input_types(&self) -> Option<TypeDef<'a>> {
|
||
|
self.namespace.commands.borrow()[self.id]
|
||
|
.input
|
||
|
.as_ref()
|
||
|
.map(|def| TypeDef::from_internal(self.namespace, def))
|
||
|
}
|
||
|
pub fn get_output_types(&self) -> Option<TypeDef> {
|
||
|
self.namespace.commands.borrow()[self.id]
|
||
|
.output
|
||
|
.as_ref()
|
||
|
.map(|def| TypeDef::from_internal(self.namespace, def))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub(super) struct InternalCommand {
|
||
|
pub(super) name: String,
|
||
|
// gosh this is hacky
|
||
|
pub(super) input: Option<InternalTypeDef>,
|
||
|
pub(super) output: Option<InternalTypeDef>,
|
||
|
}
|