Skip to content

Commit b7fd88e

Browse files
authored
refactor!: consistent naming in tauri::scope module (#7944)
1 parent 1bce739 commit b7fd88e

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

.changes/tauri-scopes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'tauri': 'patch:breaking'
3+
---
4+
5+
`tauri::scope` module is recieving a couple of consistency changes:
6+
7+
- Added `tauri::scope::fs` module.
8+
- Removed `scope::IpcScope` re-export, use `scope::ipc::Scope`.
9+
- Removed `FsScope`, `GlobPattern` and `FsScopeEvent`, use `scope::fs::Scope`, `scope::fs::Pattern` and `scope::fs::Event` respectively.

core/tauri/src/app.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@ use crate::{
1515
window::{PendingWindow, WindowEvent as RuntimeWindowEvent},
1616
ExitRequestedEventAction, RunEvent as RuntimeRunEvent,
1717
},
18-
scope::IpcScope,
18+
scope,
1919
sealed::{ManagerBase, RuntimeOrDispatch},
2020
utils::config::Config,
2121
utils::{assets::Assets, Env},
2222
Context, DeviceEventFilter, EventLoopMessage, Icon, Manager, Monitor, Runtime, Scopes,
2323
StateManager, Theme, Window,
2424
};
2525

26-
#[cfg(feature = "protocol-asset")]
27-
use crate::scope::FsScope;
28-
2926
#[cfg(desktop)]
3027
use crate::menu::{Menu, MenuEvent};
3128
#[cfg(all(desktop, feature = "tray-icon"))]
@@ -1576,9 +1573,12 @@ impl<R: Runtime> Builder<R> {
15761573
app.manage(env);
15771574

15781575
app.manage(Scopes {
1579-
ipc: IpcScope::new(&app.config()),
1576+
ipc: scope::ipc::Scope::new(&app.config()),
15801577
#[cfg(feature = "protocol-asset")]
1581-
asset_protocol: FsScope::for_fs_api(&app, &app.config().tauri.security.asset_protocol.scope)?,
1578+
asset_protocol: scope::fs::Scope::for_fs_api(
1579+
&app,
1580+
&app.config().tauri.security.asset_protocol.scope,
1581+
)?,
15821582
});
15831583

15841584
app.manage(ChannelDataIpcQueue::default());

core/tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
821821
}
822822

823823
/// Gets the scope for the IPC.
824-
fn ipc_scope(&self) -> IpcScope {
824+
fn ipc_scope(&self) -> scope::ipc::Scope {
825825
self.state::<Scopes>().inner().ipc.clone()
826826
}
827827

core/tauri/src/scope/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ use std::{
99
sync::{Arc, Mutex},
1010
};
1111

12-
pub use glob::Pattern;
1312
use tauri_utils::config::FsScope;
1413
use uuid::Uuid;
1514

15+
pub use glob::Pattern;
16+
1617
/// Scope change event.
1718
#[derive(Debug, Clone)]
1819
pub enum Event {

core/tauri/src/scope/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,37 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
mod fs;
5+
/// FS scope.
6+
pub mod fs;
67
/// IPC scope.
78
pub mod ipc;
89

9-
pub use self::ipc::Scope as IpcScope;
10-
pub use fs::{Event as FsScopeEvent, Pattern as GlobPattern, Scope as FsScope};
1110
use std::path::Path;
1211

1312
/// Managed state for all the core scopes in a tauri application.
1413
pub struct Scopes {
15-
pub(crate) ipc: IpcScope,
14+
pub(crate) ipc: ipc::Scope,
1615
#[cfg(feature = "protocol-asset")]
17-
pub(crate) asset_protocol: FsScope,
16+
pub(crate) asset_protocol: fs::Scope,
1817
}
1918

19+
#[allow(unused)]
2020
impl Scopes {
2121
/// Allows a directory on the scopes.
22-
#[allow(unused)]
2322
pub fn allow_directory<P: AsRef<Path>>(&self, path: P, recursive: bool) -> crate::Result<()> {
2423
#[cfg(feature = "protocol-asset")]
2524
self.asset_protocol.allow_directory(path, recursive)?;
2625
Ok(())
2726
}
2827

2928
/// Allows a file on the scopes.
30-
#[allow(unused)]
3129
pub fn allow_file<P: AsRef<Path>>(&self, path: P) -> crate::Result<()> {
3230
#[cfg(feature = "protocol-asset")]
3331
self.asset_protocol.allow_file(path)?;
3432
Ok(())
3533
}
3634

3735
/// Forbids a file on the scopes.
38-
#[allow(unused)]
3936
pub fn forbid_file<P: AsRef<Path>>(&self, path: P) -> crate::Result<()> {
4037
#[cfg(feature = "protocol-asset")]
4138
self.asset_protocol.forbid_file(path)?;

0 commit comments

Comments
 (0)