pub struct ExtensionPermissions { /* private fields */ }Implementations§
Source§impl ExtensionPermissions
impl ExtensionPermissions
pub fn new(extension_id: String, permissions: Vec<Permission>) -> Self
Sourcepub fn from_manifest(
extension_id: String,
manifest_permissions: Option<Vec<String>>,
) -> Result<Self, String>
pub fn from_manifest( extension_id: String, manifest_permissions: Option<Vec<String>>, ) -> Result<Self, String>
Examples found in repository?
examples/sandbox.rs (lines 17-20)
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}pub fn has_permission(&self, permission: &Permission) -> bool
Sourcepub fn check_permission(&self, permission: &Permission) -> Result<(), String>
pub fn check_permission(&self, permission: &Permission) -> Result<(), String>
Examples found in repository?
examples/sandbox.rs (line 21)
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}Trait Implementations§
Source§impl Clone for ExtensionPermissions
impl Clone for ExtensionPermissions
Source§fn clone(&self) -> ExtensionPermissions
fn clone(&self) -> ExtensionPermissions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ExtensionPermissions
impl RefUnwindSafe for ExtensionPermissions
impl Send for ExtensionPermissions
impl Sync for ExtensionPermissions
impl Unpin for ExtensionPermissions
impl UnsafeUnpin for ExtensionPermissions
impl UnwindSafe for ExtensionPermissions
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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