Skip to content

Commit 988b688

Browse files
committed
remove our as parameter when possible with our() wit fn
1 parent 78d0c1e commit 988b688

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/http/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::vfs::{FileType, VfsAction, VfsRequest, VfsResponse};
22
use crate::{
3-
get_blob, last_blob, Address, LazyLoadBlob as KiBlob, Message, Request as KiRequest,
3+
get_blob, last_blob, LazyLoadBlob as KiBlob, Message, Request as KiRequest,
44
Response as KiResponse,
55
};
66
pub use http::StatusCode;
@@ -809,11 +809,11 @@ impl HttpServer {
809809
/// An error will be returned if the file does not exist.
810810
pub fn serve_file(
811811
&mut self,
812-
our: &Address,
813812
file_path: &str,
814813
paths: Vec<&str>,
815814
config: HttpBindingConfig,
816815
) -> Result<(), HttpServerError> {
816+
let our = crate::our();
817817
let _res = KiRequest::to(("our", "vfs", "distro", "sys"))
818818
.body(
819819
serde_json::to_vec(&VfsRequest {
@@ -887,11 +887,11 @@ impl HttpServer {
887887
/// An error will be returned if the file does not exist.
888888
pub fn serve_ui(
889889
&mut self,
890-
our: &Address,
891890
directory: &str,
892891
roots: Vec<&str>,
893892
config: HttpBindingConfig,
894893
) -> Result<(), HttpServerError> {
894+
let our = crate::our();
895895
let initial_path = format!("{}/pkg/{}", our.package_id(), directory);
896896

897897
let mut queue = std::collections::VecDeque::new();

src/logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ impl<'a> tracing_subscriber::fmt::MakeWriter<'a> for TerminalWriterMaker {
119119
/// directory, `package` is the package name, `publisher.os` is the publisher of the
120120
/// package, and `process` is the process name of the process doing the logging.
121121
pub fn init_logging(
122-
our: &Address,
123122
file_level: Level,
124123
terminal_level: Level,
125124
remote: Option<RemoteLogSettings>,
126125
terminal_levels_mapping: Option<(u8, u8, u8, u8)>,
127126
) -> anyhow::Result<()> {
127+
let our = crate::our();
128128
let log_dir_path = create_drive(our.package_id(), "log", None)?;
129129
let log_file_path = format!("{log_dir_path}/{}.log", our.process());
130130
let log_file = open_file(&log_file_path, true, None)?;

src/types/message.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ impl Message {
8383
}
8484
/// Check if a `Message` was sent by a local process.
8585
/// Returns `false` if the `source` node is not our local node.
86-
pub fn is_local(&self, our: &Address) -> bool {
86+
pub fn is_local(&self) -> bool {
87+
let our = crate::our();
8788
match self {
8889
Message::Request { source, .. } => source.node == our.node,
8990
Message::Response { source, .. } => source.node == our.node,

src/types/request.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ impl Request {
235235
self
236236
}
237237
/// Attach the [`Capability`] to message this process to the next message.
238-
pub fn attach_messaging(mut self, our: &Address) -> Self {
238+
pub fn attach_messaging(mut self) -> Self {
239+
let our = crate::our();
239240
self.capabilities.extend(vec![Capability {
240-
issuer: our.clone(),
241+
issuer: our,
241242
params: "\"messaging\"".to_string(),
242243
}]);
243244
self

0 commit comments

Comments
 (0)