Make Vertex immutable

To match the C++ implementation. I meant to do this at the same time as the other metadata structs but missed it.
This commit is contained in:
Oliver Hamlet
2025-05-14 18:24:54 +01:00
parent beab02c3fe
commit 517dc6b43c
6 changed files with 60 additions and 78 deletions
+8 -8
View File
@@ -241,8 +241,14 @@ pub struct Vertex(libloot::Vertex);
#[napi]
impl Vertex {
#[napi(constructor)]
pub fn new(name: String) -> Self {
Self(libloot::Vertex::new(name))
pub fn new(name: String, out_edge_type: Option<EdgeType>) -> Self {
let mut vertex = libloot::Vertex::new(name);
if let Some(out_edge_type) = out_edge_type {
vertex = vertex.with_out_edge_type(out_edge_type.into());
}
Self(vertex)
}
#[napi(getter)]
@@ -257,12 +263,6 @@ impl Vertex {
.map(|e| e.try_into().map_err(Into::into))
.transpose()
}
#[napi(setter)]
pub fn set_out_edge_type(&mut self, out_edge_type: EdgeType) {
let out_edge_type = out_edge_type.into();
self.0.set_out_edge_type(out_edge_type);
}
}
impl From<libloot::Vertex> for Vertex {