summaryrefslogtreecommitdiff
path: root/protocol/src/address.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-18 11:19:51 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-18 11:19:51 +0800
commit2372495e1a0acb9ffead7651d8ed36a3bb98a15b (patch)
tree5f330cdf1616b1e56a7b85b2b2530cdf1422ed54 /protocol/src/address.rs
parent6f8906f06f3efd009275dc23f861f5aaba76ce72 (diff)
Add new protocol crate with basic types and operations
Diffstat (limited to 'protocol/src/address.rs')
-rw-r--r--protocol/src/address.rs56
1 files changed, 56 insertions, 0 deletions
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<Protocol>
+where
+ Protocol: BasicProtocol,
+{
+ /// Protocol of the target upstream machine
+ _p: PhantomData<Protocol>,
+
+ /// Address of the target upstream machine
+ target_address: String,
+}
+
+impl<Protocol> Upstream<Protocol>
+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<Protocol>
+where
+ Protocol: BasicProtocol,
+{
+ /// Protocol of the target upstream machine
+ _p: PhantomData<Protocol>,
+}
+
+impl<Protocol> Upstream<Protocol>
+where
+ Protocol: BasicProtocol,
+{
+ pub fn address(addr: &str) -> Self {
+ Upstream {
+ _p: PhantomData,
+ target_address: addr.to_string(),
+ }
+ }
+}
+
+impl<Protocol> Host<Protocol>
+where
+ Protocol: BasicProtocol,
+{
+ pub fn new() -> Self {
+ Host { _p: PhantomData }
+ }
+}