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