MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / put_user

Method put_user

nodedb/src/control/security/catalog/users.rs:54–72  ·  view source on GitHub ↗

Write a user record to the catalog (insert or update).

(&self, user: &StoredUser)

Source from the content-addressed store, hash-verified

52
53 /// Write a user record to the catalog (insert or update).
54 pub fn put_user(&self, user: &StoredUser) -> crate::Result<()> {
55 let bytes = zerompk::to_msgpack_vec(user).map_err(|e| catalog_err("serialize user", e))?;
56
57 let write_txn = self
58 .db
59 .begin_write()
60 .map_err(|e| catalog_err("write txn", e))?;
61 {
62 let mut table = write_txn
63 .open_table(USERS)
64 .map_err(|e| catalog_err("open users", e))?;
65 table
66 .insert(user.username.as_str(), bytes.as_slice())
67 .map_err(|e| catalog_err("insert user", e))?;
68 }
69 write_txn.commit().map_err(|e| catalog_err("commit", e))?;
70
71 Ok(())
72 }
73
74 /// Delete a user record from the catalog.
75 pub fn delete_user(&self, username: &str) -> crate::Result<()> {

Callers 10

persist_userMethod · 0.80
open_and_roundtripFunction · 0.80
delete_userFunction · 0.80
survives_restartFunction · 0.80
putFunction · 0.80
create_userFunction · 0.80
propose_and_installFunction · 0.80
propose_user_with_rolesFunction · 0.80
put_admin_userFunction · 0.80

Calls 6

begin_writeMethod · 0.80
catalog_errFunction · 0.70
insertMethod · 0.45
as_strMethod · 0.45
as_sliceMethod · 0.45
commitMethod · 0.45

Tested by 5

open_and_roundtripFunction · 0.64
delete_userFunction · 0.64
survives_restartFunction · 0.64
put_admin_userFunction · 0.64