method Principal.userId
The id of the user; AccessDenied when the caller is not a user.
Example:
fn main() io {
let ann = Principal.User("ann", [], Map.new(), false, none)
print("{ann.userId()!}")
match Principal.Anonymous.userId() {
str id => print(id)
AccessDenied _ => print("not a user")
}
}Вывод
ann not a user
pub(api) fn userId() -> str | AccessDeniedС версии. 1.0.0-beta
Возвращает
str
Ошибки
AccessDenied@error- `AccessDenied` when the caller is not a user.
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/rpc.oxl:188