Skip to content

Commit 0059670

Browse files
committed
renaming; create -> create_new
1 parent ab03ef4 commit 0059670

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

examples/protocol_greetings_with_instant_server.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(unused_variables)]
22
use colink::{
3-
extensions::instant_server::{InstantServer, LocalRegistry},
3+
extensions::instant_server::{InstantRegistry, InstantServer},
44
CoLink, Participant, ProtocolEntry,
55
};
66

@@ -36,7 +36,8 @@ impl ProtocolEntry for Receiver {
3636

3737
#[tokio::main]
3838
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
39-
let lr = LocalRegistry::new().await;
39+
let ir = InstantRegistry::new().await;
40+
// The instant server will automatically use the instant registry when there is one.
4041
let is0 = InstantServer::new();
4142
let is1 = InstantServer::new();
4243
let cl0 = is0.get_colink().switch_to_generated_user().await?;

src/extensions/instant_server.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::{utils::get_colink_home, CoLink};
22
use rand::Rng;
33
use std::{
44
fs::File,
5-
io::Write,
65
path::Path,
76
process::{Child, Command, Stdio},
87
};
@@ -106,25 +105,28 @@ impl InstantServer {
106105
}
107106
}
108107

109-
pub struct LocalRegistry {
108+
pub struct InstantRegistry {
110109
_instant_server: InstantServer,
111110
}
112111

113-
impl Drop for LocalRegistry {
112+
impl Drop for InstantRegistry {
114113
fn drop(&mut self) {
115114
let colink_home = get_colink_home().unwrap();
116-
let registry_file = Path::new(&colink_home).join("registry.conf");
115+
let registry_file = Path::new(&colink_home).join("reg_config");
117116
std::fs::remove_file(&registry_file).unwrap();
118117
}
119118
}
120119

121-
impl LocalRegistry {
120+
impl InstantRegistry {
122121
pub async fn new() -> Self {
123122
let is = InstantServer::new();
124123
let colink_home = get_colink_home().unwrap();
125-
let registry_file = Path::new(&colink_home).join("registry.conf");
126-
let mut file = File::create(&registry_file).unwrap();
127-
file.write_all(b"new_registry").unwrap();
124+
let registry_file = Path::new(&colink_home).join("reg_config");
125+
let _file = File::options()
126+
.write(true)
127+
.create_new(true)
128+
.open(&registry_file)
129+
.unwrap();
128130
is.get_colink().switch_to_generated_user().await.unwrap();
129131
Self {
130132
_instant_server: is,

0 commit comments

Comments
 (0)