pub struct CodexAuthManager { /* private fields */ }Expand description
A manager rooted at one Codex home directory.
Implementations§
Source§impl CodexAuthManager
impl CodexAuthManager
Sourcepub fn from_env() -> Result<Self, Error>
pub fn from_env() -> Result<Self, Error>
Create a manager from $CODEX_HOME, or $HOME/.codex when $CODEX_HOME is unset.
The stored path is absolute. The directory is not created by this method.
§Errors
Returns an error when neither environment variable can be read or the current directory cannot be determined while absolutizing a relative path.
Sourcepub fn new(codex_home: impl AsRef<Path>) -> Result<Self, Error>
pub fn new(codex_home: impl AsRef<Path>) -> Result<Self, Error>
Create a manager for codex_home.
The stored path is absolute. The directory is not created by this method.
§Errors
Returns an error when the current directory cannot be determined while absolutizing a relative path.
Sourcepub fn codex_home(&self) -> &Path
pub fn codex_home(&self) -> &Path
The Codex home directory this manager uses.
Sourcepub fn status(&self) -> Result<AuthStatus, Error>
pub fn status(&self) -> Result<AuthStatus, Error>
Return the current auth status.
§Errors
Returns an error when CAM cannot inspect auth.json or read its symlink target.
Sourcepub fn list(&self) -> Result<Vec<Identity>, Error>
pub fn list(&self) -> Result<Vec<Identity>, Error>
List identities from the manager directory.
Broken identity entries are included. Missing manager directories produce an empty list.
§Errors
Returns an error when the manager directory or one of its entries cannot be inspected.
Sourcepub fn capture(
&self,
identity: &IdentityName,
options: CaptureOptions,
) -> Result<(), Error>
pub fn capture( &self, identity: &IdentityName, options: CaptureOptions, ) -> Result<(), Error>
Capture the native auth file into an identity and make it active.
§Errors
Returns an error when there is no native auth file, the destination identity already
exists without force, the destination is broken, or a filesystem operation fails.
Sourcepub fn use_identity(
&self,
identity: &IdentityName,
options: UseOptions,
) -> Result<(), Error>
pub fn use_identity( &self, identity: &IdentityName, options: UseOptions, ) -> Result<(), Error>
Make an existing identity active.
§Errors
Returns an error when the identity is missing or broken, a native auth file would be
discarded without force, the auth state is unknown, or a filesystem operation fails.
Trait Implementations§
Source§impl Clone for CodexAuthManager
impl Clone for CodexAuthManager
Source§fn clone(&self) -> CodexAuthManager
fn clone(&self) -> CodexAuthManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more