Skip to main content

Vine/Server/Notification/Support/
UnregisterByHandle.rs

1//! Shared helper for provider-unregistration notification atoms.
2//!
3//! Every `unregister_*_provider` wire method does the same three steps:
4//! read the `handle` u32 from the parameter, call
5//! `VineHost::UnregisterProvider`, and emit a tagged dev-log line. This
6//! function centralises that triple so each atom shrinks to a single
7//! delegation call.
8//!
9//! `TypeName` is the provider kind string used in the log line
10//! (e.g. `"authentication"`, `"debug_adapter"`, `"task"`).
11
12use serde_json::Value;
13
14use crate::{Host::VineHost, dev_log};
15
16pub fn UnregisterByHandle(Host:&dyn VineHost, Parameter:&Value, TypeName:&str) {
17	let Handle = Parameter.get("handle").and_then(Value::as_u64).unwrap_or(0) as u32;
18
19	if Handle == 0 {
20		dev_log!("provider-register", "[ProviderUnregister] {} skip: missing handle", TypeName);
21
22		return;
23	}
24
25	Host.UnregisterProvider(Handle);
26
27	dev_log!("provider-register", "[ProviderUnregister] {} handle={}", TypeName, Handle);
28}