Skip to content

Commit

Permalink
fundamentals: add the to/from wire methods
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Nov 13, 2024
1 parent 42d23c6 commit f8ed8de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ffi/ffi-fundamentals/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ffi-fundamentals"
version = "0.0.1-alpha.4"
version = "0.0.1-alpha.5"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
14 changes: 14 additions & 0 deletions fundamentals/src/bolt/bolt1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ impl Init {
init_tlvs: Stream::default(),
})
}

fn wire(&self) -> PyResult<Vec<u8>> {
use crate::core::ToWire;

let mut buff = Vec::new();
self.to_wire(&mut buff)?;
Ok(buff)
}

fn wire_decode(&self, buff: Vec<u8>) -> PyResult<Init> {
let mut cursor = std::io::Cursor::new(buff);
let init = Init::from_wire(&mut cursor)?;
Ok(init)
}
}

#[cfg_attr(feature = "pyo3", pyclass(set_all))]
Expand Down

0 comments on commit f8ed8de

Please sign in to comment.