mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-20 19:31:00 +03:00
add the base crate and repoint the moved modules at it (#16107)
* add the base crate and repoint the moved modules at it `libs/base` (crate `base`) takes the parts of hbb_common that only this app uses: `fs`, `platform`, `keyboard`, `message.proto`, and 145 of the 177 `config::keys` constants. hbb_common keeps what the server names, and the 32 keys it reads itself are re-exported from `base::config::keys` so call sites still see the full set through one path. Sources move verbatim. The only edits inside them are `crate::` prefixes that now have to say `hbb_common::`; `keyboard.rs` and `platform/windows.rs` are byte-identical. The crate stays on edition 2018, the edition the moved code was written under. `log`, `lazy_static` and `anyhow` become direct dependencies so the bare paths in that code resolve exactly as before, and its winapi features are spelled out rather than left to feature unification. Two call sites outside Rust and Cargo had to follow the move: the Android protobuf source dir, which still pointed at hbb_common/protos for message.proto, and the three AGENTS.md entries that named hbb_common for options, protos and file transfer. `scrap`'s `drm` feature now forwards to `base/wayland_probe`. Left pointing at hbb_common it would still have compiled, silently dropping the Wayland socket-probe fallback, so that forward is verified by a build with and without the feature. `config::keys` carries a test asserting its names stay disjoint from the ones hbb_common kept: the glob re-export and the local constants share a namespace, and Rust prefers the local item silently, so a name added to both sides would otherwise let client and server disagree with no diagnostic. Verified: macOS and Linux, debug and release, `--all-targets`; the 177 key constants diffed name-for-name and value-for-value; the generated protobuf types compared before and after; every `#[cfg]` gate on a moved import checked against its original; and every file that was `rustfmt`-clean before this change still is, compared against master file by file. Windows is checked by inspection only -- it cannot be compiled here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab * one `use` per crate, and write the rule down `fs.rs` came out of the move with two ungated `use hbb_common::` statements, because the original single `use crate::{...}` had to give up `message_proto` to the new crate and the rest was left in a second block. Fold it back into one. A scan of the whole tree for the same shape finds nothing else: every other file with more than one top-level `use base::` or `use hbb_common::` is split by a `#[cfg]` that does not cover the whole block, or by `pub use` next to `use`. Those are the cases that cannot merge, so AGENTS.md now states both the rule and the exemption. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,20 +5,24 @@ use crate::ipc::{self, Data};
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::{clipboard::ClipboardSide, ipc::ClipboardNonFile};
|
||||
#[cfg(target_os = "windows")]
|
||||
use clipboard::ContextSend;
|
||||
use base::config::keys::*;
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
use hbb_common::fs::serialize_transfer_job;
|
||||
use base::fs::serialize_transfer_job;
|
||||
use base::{
|
||||
config::keys::{OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW, OPTION_FILE_TRANSFER_MAX_FILES},
|
||||
fs::{self, get_string, is_write_need_confirmation, new_send_confirm, DigestCheckResult},
|
||||
message_proto::*,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
use clipboard::ContextSend;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::tokio::sync::mpsc::unbounded_channel;
|
||||
#[cfg(target_os = "windows")]
|
||||
use hbb_common::tokio::sync::Mutex as TokioMutex;
|
||||
use hbb_common::{
|
||||
allow_err, bail,
|
||||
config::{
|
||||
keys::{OPTION_ENABLE_PERM_CHANGE_IN_ACCEPT_WINDOW, OPTION_FILE_TRANSFER_MAX_FILES},
|
||||
option2bool, Config,
|
||||
},
|
||||
fs::{self, get_string, is_write_need_confirmation, new_send_confirm, DigestCheckResult},
|
||||
config::{option2bool, Config},
|
||||
log,
|
||||
message_proto::*,
|
||||
protobuf::Message as _,
|
||||
tokio::{
|
||||
self,
|
||||
@@ -27,8 +31,6 @@ use hbb_common::{
|
||||
},
|
||||
ResultType,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
use hbb_common::{config::keys::*, tokio::sync::Mutex as TokioMutex};
|
||||
use serde_derive::Serialize;
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||
use std::iter::FromIterator;
|
||||
@@ -1400,7 +1402,7 @@ async fn start_read_job(
|
||||
/// Process read jobs periodically, reading file blocks and sending them via IPC.
|
||||
///
|
||||
/// NOTE: This is the CM-side equivalent of `handle_read_jobs()` in
|
||||
/// `libs/hbb_common/src/fs.rs`. The logic mirrors that implementation
|
||||
/// `libs/base/src/fs.rs`. The logic mirrors that implementation
|
||||
/// but communicates via IPC instead of direct network stream.
|
||||
/// When modifying job processing logic, ensure both implementations stay in sync.
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
@@ -1499,7 +1501,7 @@ async fn handle_read_jobs_tick(
|
||||
/// Initialize a read job's data stream and handle digest sending for overwrite detection.
|
||||
///
|
||||
/// NOTE: This is the CM-side equivalent of `TransferJob::init_data_stream()` in
|
||||
/// `libs/hbb_common/src/fs.rs`. It calls `init_data_stream_for_cm()` and sends
|
||||
/// `libs/base/src/fs.rs`. It calls `init_data_stream_for_cm()` and sends
|
||||
/// digest via IPC instead of direct network stream.
|
||||
/// When modifying initialization or digest logic, ensure both paths stay in sync.
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
@@ -1777,10 +1779,8 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::ipc::Data;
|
||||
use hbb_common::{
|
||||
message_proto::{FileDirectory, Message},
|
||||
tokio::{runtime::Runtime, sync::mpsc::unbounded_channel},
|
||||
};
|
||||
use base::message_proto::{FileDirectory, Message};
|
||||
use hbb_common::tokio::{runtime::Runtime, sync::mpsc::unbounded_channel};
|
||||
use std::fs;
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user