pub struct SharedCore { /* private fields */ }Expand description
SharedCore wraps the 1Password WASM plugin for thread-safe access.
The WASM runtime is single-threaded, so we use a mutex to serialize access. This follows the same pattern as the official 1Password Go SDK.
Implementations§
Sourcepub fn get_or_init() -> Result<&'static Mutex<Option<Self>>, SecretError>
pub fn get_or_init() -> Result<&'static Mutex<Option<Self>>, SecretError>
Get or initialize the shared core.
On first call, loads the WASM from disk and initializes the plugin. Subsequent calls return the cached instance.
§Errors
Returns an error if:
- The shared core lock cannot be acquired
- The WASM file cannot be loaded
- The Extism plugin fails to initialize
Sourcepub fn init_client(&mut self, token: &str) -> Result<u64, SecretError>
pub fn init_client(&mut self, token: &str) -> Result<u64, SecretError>
Initialize a new 1Password client.
Returns a client ID that can be used for subsequent invoke calls.
§Errors
Returns an error if:
- The client configuration cannot be serialized
- The WASM
init_clientcall fails - The response cannot be parsed
- 1Password returns an authentication error
Sourcepub fn invoke(
&mut self,
client_id: u64,
method: &str,
params: &Map<String, Value>,
context: &str,
) -> Result<String, SecretError>
pub fn invoke( &mut self, client_id: u64, method: &str, params: &Map<String, Value>, context: &str, ) -> Result<String, SecretError>
Invoke a method on the 1Password client.
The method name and parameters depend on the specific operation.
For resolving secrets, use method SecretsResolve with the secret reference.
The context parameter is used for error messages to identify which secret failed.
§Errors
Returns an error if:
- The invoke request cannot be serialized
- The WASM invoke call fails
- The response cannot be parsed
- 1Password returns an error for the operation
Sourcepub fn release_client(&mut self, client_id: u64)
pub fn release_client(&mut self, client_id: u64)
Release a 1Password client.
This should be called when the client is no longer needed.
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more