From 2372495e1a0acb9ffead7651d8ed36a3bb98a15b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 18 Mar 2026 11:19:51 +0800 Subject: Add new protocol crate with basic types and operations --- protocol/src/address.rs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 protocol/src/address.rs (limited to 'protocol/src/address.rs') diff --git a/protocol/src/address.rs b/protocol/src/address.rs new file mode 100644 index 0000000..ab49df4 --- /dev/null +++ b/protocol/src/address.rs @@ -0,0 +1,56 @@ +use crate::protocol::BasicProtocol; +use std::marker::PhantomData; + +/// Upstream, used by Workspace to describe the protocol of UpstreamVault +pub struct Upstream +where + Protocol: BasicProtocol, +{ + /// Protocol of the target upstream machine + _p: PhantomData, + + /// Address of the target upstream machine + target_address: String, +} + +impl Upstream +where + Protocol: BasicProtocol, +{ + pub fn new(addr: &str) -> Self { + Upstream { + _p: PhantomData, + target_address: addr.to_string(), + } + } +} + +/// Host, used by Vault to describe its own protocol +pub struct Host +where + Protocol: BasicProtocol, +{ + /// Protocol of the target upstream machine + _p: PhantomData, +} + +impl Upstream +where + Protocol: BasicProtocol, +{ + pub fn address(addr: &str) -> Self { + Upstream { + _p: PhantomData, + target_address: addr.to_string(), + } + } +} + +impl Host +where + Protocol: BasicProtocol, +{ + pub fn new() -> Self { + Host { _p: PhantomData } + } +} -- cgit