aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_server/src/cmd/extendable.rs
blob: 03d7ce98fd457f2837d47cb8ca39cf99018e7216 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright (C) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only

pub trait Parsable {
  fn parse(data: Vec<u8>) -> Self;
}

pub trait Creatable {
  fn create(&self) -> Vec<u8>;
}

/// Having to do this makes me with there was operator overloading in Rust.
///
/// I *could* do this with a macro but since Text is the only struct that
/// implements this trait, it shouldn't be that big of a deal.
pub trait ParsableWithArguments {
  fn parse(data: Vec<u8>, args: &[&str]) -> Self;
}