pub struct SecretStorage { /* private fields */ }Implementations§
Source§impl SecretStorage
impl SecretStorage
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/sandbox.rs (line 30)
9fn main() -> Result<(), Box<dyn std::error::Error>> {
10 // Path validation
11 let mut validator = PathValidator::new();
12 validator.add_workspace_folder(std::env::current_dir()?);
13 let safe = validator.validate_path("file:///workspace/src/main.rs")?;
14 println!("Validated path: {}", safe.display());
15
16 // Permissions
17 let perms = ExtensionPermissions::from_manifest(
18 "my-extension".to_string(),
19 Some(vec!["fileSystem.read".to_string()]),
20 )?;
21 perms.check_permission(&Permission::FileSystemRead)?;
22 println!("Permission check passed.");
23
24 // Rate limiting
25 let limiter = RateLimiter::new();
26 limiter.check_rate_limit("my-extension")?;
27 println!("Rate limit check passed.");
28
29 // Secret storage
30 let secrets = SecretStorage::new();
31 secrets.set("my-extension", "api_key", "secret-value")?;
32 let value = secrets.get("my-extension", "api_key")?;
33 println!("Retrieved secret: {}", value.unwrap_or_default());
34
35 Ok(())
36}Sourcepub fn get(
&self,
extension_id: &str,
key: &str,
) -> Result<Option<String>, String>
pub fn get( &self, extension_id: &str, key: &str, ) -> Result<Option<String>, String>
Get a secret for an extension
Examples found in repository?
examples/sandbox.rs (line 32)
9fn main() -> Result<(), Box<dyn std::error::Error>> {
10 // Path validation
11 let mut validator = PathValidator::new();
12 validator.add_workspace_folder(std::env::current_dir()?);
13 let safe = validator.validate_path("file:///workspace/src/main.rs")?;
14 println!("Validated path: {}", safe.display());
15
16 // Permissions
17 let perms = ExtensionPermissions::from_manifest(
18 "my-extension".to_string(),
19 Some(vec!["fileSystem.read".to_string()]),
20 )?;
21 perms.check_permission(&Permission::FileSystemRead)?;
22 println!("Permission check passed.");
23
24 // Rate limiting
25 let limiter = RateLimiter::new();
26 limiter.check_rate_limit("my-extension")?;
27 println!("Rate limit check passed.");
28
29 // Secret storage
30 let secrets = SecretStorage::new();
31 secrets.set("my-extension", "api_key", "secret-value")?;
32 let value = secrets.get("my-extension", "api_key")?;
33 println!("Retrieved secret: {}", value.unwrap_or_default());
34
35 Ok(())
36}Sourcepub fn set(
&self,
extension_id: &str,
key: &str,
value: &str,
) -> Result<(), String>
pub fn set( &self, extension_id: &str, key: &str, value: &str, ) -> Result<(), String>
Store a secret for an extension
Examples found in repository?
examples/sandbox.rs (line 31)
9fn main() -> Result<(), Box<dyn std::error::Error>> {
10 // Path validation
11 let mut validator = PathValidator::new();
12 validator.add_workspace_folder(std::env::current_dir()?);
13 let safe = validator.validate_path("file:///workspace/src/main.rs")?;
14 println!("Validated path: {}", safe.display());
15
16 // Permissions
17 let perms = ExtensionPermissions::from_manifest(
18 "my-extension".to_string(),
19 Some(vec!["fileSystem.read".to_string()]),
20 )?;
21 perms.check_permission(&Permission::FileSystemRead)?;
22 println!("Permission check passed.");
23
24 // Rate limiting
25 let limiter = RateLimiter::new();
26 limiter.check_rate_limit("my-extension")?;
27 println!("Rate limit check passed.");
28
29 // Secret storage
30 let secrets = SecretStorage::new();
31 secrets.set("my-extension", "api_key", "secret-value")?;
32 let value = secrets.get("my-extension", "api_key")?;
33 println!("Retrieved secret: {}", value.unwrap_or_default());
34
35 Ok(())
36}Sourcepub fn delete(&self, extension_id: &str, key: &str) -> Result<(), String>
pub fn delete(&self, extension_id: &str, key: &str) -> Result<(), String>
Delete a secret for an extension
Sourcepub fn delete_all_for_extension(&self, extension_id: &str) -> Result<(), String>
pub fn delete_all_for_extension(&self, extension_id: &str) -> Result<(), String>
Delete all secrets for an extension (used when uninstalling)
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear all cached secrets. Called on session shutdown to minimize the window where secrets are in memory.
Trait Implementations§
Source§impl Default for SecretStorage
impl Default for SecretStorage
Auto Trait Implementations§
impl !Freeze for SecretStorage
impl RefUnwindSafe for SecretStorage
impl Send for SecretStorage
impl Sync for SecretStorage
impl Unpin for SecretStorage
impl UnsafeUnpin for SecretStorage
impl UnwindSafe for SecretStorage
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
Mutably borrows from an owned value. Read more
Source§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>
Converts
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>
Converts
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