pub struct Identity {
pub server: Option<String>,
pub device_id: Option<String>,
pub enrollment_id: Option<String>,
pub user_code: Option<String>,
/* private fields */
}Expand description
The worker’s key, and how far its enrolment has got.
Fields§
§server: Option<String>The server it was made for, as RECALL_WORKER_SERVER named it.
None only in a file an earlier build wrote.
device_id: Option<String>dev_…, once approved.
enrollment_id: Option<String>The enrolment waiting for approval, so a restart keeps polling the same one rather than asking the owner to approve a second code.
user_code: Option<String>That enrolment’s code, as the owner types it.
Implementations§
Source§impl Identity
impl Identity
Sourcepub fn from_seed(seed: [u8; 32]) -> Self
pub fn from_seed(seed: [u8; 32]) -> Self
A key from a known seed; tests use this to be repeatable.
Sourcepub fn load_or_create(dir: &Path, server: &str) -> Result<Self>
pub fn load_or_create(dir: &Path, server: &str) -> Result<Self>
Reads the identity in dir, or makes and saves a new one for
server when there is none. A file that exists but does not read is
an error, never silently replaced: replacing it would enrol a second
worker and orphan the first.
An identity that exists is answered as it is, whatever server it was made for; comparing that with the one configured is the caller’s.
Sourcepub fn load(dir: &Path) -> Result<Option<Self>>
pub fn load(dir: &Path) -> Result<Option<Self>>
Reads the identity in dir: None when there is none yet.
Sourcepub fn save(&self, dir: &Path) -> Result<()>
pub fn save(&self, dir: &Path) -> Result<()>
Writes the identity to dir, readable by its owner only, through a
temporary file renamed over the old one, so a crash mid-write
leaves the previous identity rather than half of one.
Sourcepub fn key(&self) -> &SigningKey
pub fn key(&self) -> &SigningKey
The signing key.
Sourcepub fn public_key(&self) -> String
pub fn public_key(&self) -> String
The public key, as the server stores it.
Sourcepub fn fingerprint(&self) -> String
pub fn fingerprint(&self) -> String
SHA256:…, which the owner compares before approving.