Skip to main content

device_scope_for

Function device_scope_for 

Source
pub fn device_scope_for(method: &Method, path: &str) -> Option<DeviceScope>
Expand description

The scope a device needs for method on path, or None when the route is closed to devices (spec 3.3 §7.2, §10 K2, S-I10). path may carry the /api prefix and a query.

§Example

use axum::http::Method;
use adk_kernel::pairing::{DeviceScope, device_scope_for};

assert_eq!(device_scope_for(&Method::POST, "/api/approvals/a1/decide"), Some(DeviceScope::Decide));
assert_eq!(device_scope_for(&Method::GET, "/kernel/processes?limit=5"), Some(DeviceScope::Read));
assert_eq!(device_scope_for(&Method::POST, "/api/kernel/freeze"), Some(DeviceScope::Stop));
assert_eq!(device_scope_for(&Method::POST, "/api/kernel/unfreeze"), None);
assert_eq!(device_scope_for(&Method::POST, "/api/kernel/pairing"), None);