tor-linkspec: Add a constructor for UnparsedLinkSpec

This commit is contained in:
Nick Mathewson 2023-03-06 08:45:05 -05:00
parent e60ab8087d
commit 7129807843
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1 @@
ADDED: Constructor for UnparedLinkSpec

View File

@ -160,6 +160,16 @@ pub struct UnparsedLinkSpec {
body: Vec<u8>,
}
impl UnparsedLinkSpec {
/// Create a new `UnparsedLinkSpec`.
pub fn new(lstype: u8, body: impl Into<Vec<u8>>) -> Self {
UnparsedLinkSpec {
lstype,
body: body.into(),
}
}
}
impl Readable for UnparsedLinkSpec {
fn take_from(r: &mut Reader<'_>) -> Result<Self> {
let lstype = r.take_u8()?;