1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::io::Result as Res;

use endio::Serialize;
use endio_bit::BEBitWriter;
use lu_packets_derive::{BitVariantTests, ReplicaSerde};

use crate::common::{LuVarWString, ObjId};
use super::{ComponentConstruction, ComponentProtocol, ComponentSerialization};

#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct ModuleAssemblyInfo {
	pub assembly_id: Option<ObjId>,
	pub use_optional_parts: bool,
	pub blob: LuVarWString<u16>,
}

#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct ModuleAssemblyConstruction {
	pub module_assembly_info: Option<ModuleAssemblyInfo>,
}

impl ComponentConstruction for ModuleAssemblyConstruction {
	fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
		self.serialize(writer)
	}
}

#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct ModuleAssemblySerialization {}

impl ComponentSerialization for ModuleAssemblySerialization {
	fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
		self.serialize(writer)
	}
}

pub struct ModuleAssemblyProtocol;

impl ComponentProtocol for ModuleAssemblyProtocol {
	type Construction = ModuleAssemblyConstruction;
	type Serialization = ModuleAssemblySerialization;
}