OnePasswordBuilder

Struct OnePasswordBuilder 

Source
pub struct OnePasswordBuilder { /* private fields */ }
Expand description

Builder for configuring and creating a OnePassword client.

Use OnePassword::from_env() or OnePassword::from_token() to create a builder, then configure it and call connect() to establish the connection.

§Examples

use corteq_onepassword::OnePassword;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // From environment variable
    let client = OnePassword::from_env()?
        .integration("my-app", "1.0.0")
        .connect()
        .await?;

    // From explicit token (use env var in production)
    let token = std::env::var("MY_TOKEN")?;
    let client = OnePassword::from_token(&token)?
        .integration("my-app", "1.0.0")
        .connect()
        .await?;
    Ok(())
}

Implementations§

Source§

impl OnePasswordBuilder

Source

pub fn integration(self, name: &str, version: &str) -> Self

Set the integration name and version for 1Password audit logs.

This metadata appears in 1Password’s audit logs, helping identify which application is accessing secrets.

If not set, defaults to corteq-onepassword and the crate version.

§Examples
use corteq_onepassword::OnePassword;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = OnePassword::from_env()?
        .integration("contact-guard", "2.1.0")
        .connect()
        .await?;
    Ok(())
}
Source

pub async fn connect(self) -> Result<OnePassword>

Connect to 1Password and create the client.

This establishes a session with 1Password using the configured service account token.

§Errors

Returns an error if:

  • The native library cannot be loaded
  • Authentication fails (invalid or expired token)
  • Network issues prevent connection
§Examples
use corteq_onepassword::OnePassword;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = OnePassword::from_env()?
        .connect()
        .await?;
    Ok(())
}
Source

pub fn connect_blocking(self) -> Result<OnePassword>

Connect to 1Password synchronously (blocking).

This is equivalent to connect() but blocks the current thread instead of returning a future.

§Feature Flag

This method requires the blocking feature to be enabled.

§Examples
use corteq_onepassword::OnePassword;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = OnePassword::from_env()?
        .connect_blocking()?;
    Ok(())
}

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more