Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 397d8a8

Browse files
committed
remove _policy suffix
1 parent 4154aff commit 397d8a8

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

examples/pulsebeam.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Context;
22
use clap::{Parser, Subcommand};
3-
use pulsebeam_core::{App, PeerPolicy, PeerClaims};
3+
use pulsebeam_core::{App, PeerClaims, PeerPolicy};
44

55
#[derive(Parser)]
66
#[command(author, version, about, long_about = None)]
@@ -70,8 +70,8 @@ fn main() -> anyhow::Result<()> {
7070
let parts: Vec<&str> = s.split(':').collect();
7171
if parts.len() == 2 {
7272
Some(PeerPolicy {
73-
group_id_policy: parts[0].to_string(),
74-
peer_id_policy: parts[1].to_string(),
73+
group_id: parts[0].to_string(),
74+
peer_id: parts[1].to_string(),
7575
})
7676
} else {
7777
None

src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ impl From<anyhow::Error> for AppError {
115115
#[derive(Debug, PartialEq, Serialize, Deserialize, Default, Clone)]
116116
pub struct PeerClaims {
117117
#[wasm_bindgen(skip)]
118+
#[serde(rename = "gid")]
118119
pub group_id: String,
119120
#[wasm_bindgen(skip)]
121+
#[serde(rename = "pid")]
120122
pub peer_id: String,
121123

122124
#[wasm_bindgen(skip)]
125+
#[serde(rename = "ap")]
123126
pub allow_policy: Option<PeerPolicy>,
124127
}
125128

@@ -144,7 +147,7 @@ impl PeerClaims {
144147
}
145148
}
146149
#[wasm_bindgen(js_name = "setAllowPolicy")]
147-
pub fn set_allow_policy(&mut self, claims: &PeerPolicy) {
150+
pub fn set_allow(&mut self, claims: &PeerPolicy) {
148151
self.allow_policy = Some(claims.clone());
149152
}
150153
}
@@ -174,21 +177,21 @@ impl PeerClaims {
174177
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
175178
pub struct PeerPolicy {
176179
#[wasm_bindgen(skip)]
177-
pub group_id_policy: String,
180+
pub group_id: String,
178181
#[wasm_bindgen(skip)]
179-
pub peer_id_policy: String,
182+
pub peer_id: String,
180183
}
181184

182185
#[wasm_bindgen]
183186
impl PeerPolicy {
184-
/// Create `PeerPolicy` instance using provided `group_id_policy` and
185-
/// `peer_id_policy`.
187+
/// Create `PeerPolicy` instance using provided `group_id` and
188+
/// `peer_id`.
186189
///
187190
/// This is used in conjunction with `PeerClaims` to scope connection permissions.
188191
///
189-
/// `group_id_policy` - Desired rule for allowed groupIds
192+
/// `group_id` - Desired rule for allowed groupIds
190193
///
191-
/// `peer_id_policy` - Desired for allowed peerIds
194+
/// `peer_id` - Desired for allowed peerIds
192195
///
193196
/// Policy string must be:
194197
/// - Valid UTF-8 string
@@ -203,10 +206,10 @@ impl PeerPolicy {
203206
///
204207
/// `const rule = new PeerPolicy("myGroup*", "*");`
205208
#[wasm_bindgen(constructor)]
206-
pub fn new(group_id_policy: &str, peer_id_policy: &str) -> Self {
209+
pub fn new(group_id: &str, peer_id: &str) -> Self {
207210
Self {
208-
group_id_policy: group_id_policy.to_owned(),
209-
peer_id_policy: peer_id_policy.to_owned(),
211+
group_id: group_id.to_owned(),
212+
peer_id: peer_id.to_owned(),
210213
}
211214
}
212215
}

0 commit comments

Comments
 (0)