pub struct DeviceRegistry { /* private fields */ }Expand description
Registry of paired devices backed by SQLite.
Implementations§
Source§impl DeviceRegistry
impl DeviceRegistry
pub fn new(workspace_dir: &Path) -> Self
pub fn register(&self, token_hash: String, info: DeviceInfo)
pub fn list(&self) -> Vec<DeviceInfo>
Sourcepub fn revoke(&self, device_id: &str) -> Result<Option<String>, Error>
pub fn revoke(&self, device_id: &str) -> Result<Option<String>, Error>
Delete a device by id and return its SHA-256 token hash so the caller can revoke the matching bearer token.
Ok(None) means the device did not exist; real SQLite errors are
propagated so handlers can distinguish “nothing to do” from “DB is
broken” — confusing the two during incident response is dangerous.
Uses DELETE … RETURNING (SQLite ≥ 3.35) so the read and delete are
atomic under concurrent revoke calls.
Sourcepub fn clear(&self) -> Result<usize, Error>
pub fn clear(&self) -> Result<usize, Error>
Delete every device row and clear the in-memory cache. Returns the
number of rows removed. Pairs with PairingGuard::revoke_all_tokens
for the “rotate after compromise — nuke everything” path so the device
registry does not silently coexist with the now-revoked token set.
pub fn update_last_seen(&self, token_hash: &str)
Sourcepub fn update_capabilities(
&self,
token_hash: &str,
capabilities: Vec<String>,
) -> bool
pub fn update_capabilities( &self, token_hash: &str, capabilities: Vec<String>, ) -> bool
Replace the capability list for the device identified by token_hash.
Returns true if a row was updated.
pub fn device_count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DeviceRegistry
impl !RefUnwindSafe for DeviceRegistry
impl Send for DeviceRegistry
impl Sync for DeviceRegistry
impl Unpin for DeviceRegistry
impl UnsafeUnpin for DeviceRegistry
impl UnwindSafe for DeviceRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more