diff --git a/src/http/client.rs b/src/http/client.rs index 8812a87..a0a8c4e 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use std::str::FromStr; use thiserror::Error; -/// [`crate::Request`] type sent to the `http_client:distro:sys` service in order to open a +/// [`crate::Request`] type sent to the `http-client:distro:sys` service in order to open a /// WebSocket connection, send a WebSocket message on an existing connection, or /// send an HTTP request. /// @@ -31,7 +31,7 @@ pub enum HttpClientAction { } /// HTTP Request type that can be shared over Wasm boundary to apps. -/// This is the one you send to the `http_client:distro:sys` service. +/// This is the one you send to the `http-client:distro:sys` service. /// /// BODY is stored in the lazy_load_blob, as bytes /// @@ -48,7 +48,7 @@ pub struct OutgoingHttpRequest { } /// [`crate::Request`] that comes from an open WebSocket client connection in the -/// `http_client:distro:sys` service. Be prepared to receive these after +/// `http-client:distro:sys` service. Be prepared to receive these after /// using a [`HttpClientAction::WebSocketOpen`] to open a connection. #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum HttpClientRequest { @@ -61,7 +61,7 @@ pub enum HttpClientRequest { }, } -/// [`crate::Response`] type received from the `http_client:distro:sys` service after +/// [`crate::Response`] type received from the `http-client:distro:sys` service after /// sending a successful [`HttpClientAction`] to it. #[derive(Debug, Serialize, Deserialize)] pub enum HttpClientResponse { @@ -72,15 +72,15 @@ pub enum HttpClientResponse { #[derive(Error, Debug, Serialize, Deserialize)] pub enum HttpClientError { // HTTP errors - #[error("http_client: request is not valid HttpClientRequest: {req}.")] + #[error("http-client: request is not valid HttpClientRequest: {req}.")] BadRequest { req: String }, - #[error("http_client: http method not supported: {method}.")] + #[error("http-client: http method not supported: {method}.")] BadMethod { method: String }, - #[error("http_client: url could not be parsed: {url}.")] + #[error("http-client: url could not be parsed: {url}.")] BadUrl { url: String }, - #[error("http_client: http version not supported: {version}.")] + #[error("http-client: http version not supported: {version}.")] BadVersion { version: String }, - #[error("http_client: failed to execute request {error}.")] + #[error("http-client: failed to execute request {error}.")] RequestFailed { error: String }, // WebSocket errors @@ -105,7 +105,7 @@ pub fn send_request( timeout: Option, body: Vec, ) { - let req = KiRequest::to(("our", "http_client", "distro", "sys")) + let req = KiRequest::to(("our", "http-client", "distro", "sys")) .body( serde_json::to_vec(&HttpClientAction::Http(OutgoingHttpRequest { method: method.to_string(), @@ -123,7 +123,7 @@ pub fn send_request( } } -/// Make an HTTP request using http_client and await its response. +/// Make an HTTP request using http-client and await its response. /// /// Returns HTTP response from the `http` crate if successful, with the body type as bytes. pub fn send_request_await_response( @@ -133,7 +133,7 @@ pub fn send_request_await_response( timeout: u64, body: Vec, ) -> std::result::Result>, HttpClientError> { - let res = KiRequest::to(("our", "http_client", "distro", "sys")) + let res = KiRequest::to(("our", "http-client", "distro", "sys")) .body( serde_json::to_vec(&HttpClientAction::Http(OutgoingHttpRequest { method: method.to_string(), @@ -150,7 +150,7 @@ pub fn send_request_await_response( .unwrap(); let Ok(Message::Response { body, .. }) = res else { return Err(HttpClientError::RequestFailed { - error: "http_client timed out".to_string(), + error: "http-client timed out".to_string(), }); }; let resp = match serde_json::from_slice::< @@ -160,13 +160,13 @@ pub fn send_request_await_response( Ok(Ok(HttpClientResponse::Http(resp))) => resp, Ok(Ok(HttpClientResponse::WebSocketAck)) => { return Err(HttpClientError::RequestFailed { - error: "http_client gave unexpected response".to_string(), + error: "http-client gave unexpected response".to_string(), }) } Ok(Err(e)) => return Err(e), Err(e) => { return Err(HttpClientError::RequestFailed { - error: format!("http_client gave invalid response: {e:?}"), + error: format!("http-client gave invalid response: {e:?}"), }) } }; @@ -176,12 +176,12 @@ pub fn send_request_await_response( for (key, value) in &resp.headers { let Ok(key) = http::header::HeaderName::from_str(key) else { return Err(HttpClientError::RequestFailed { - error: format!("http_client gave invalid header key: {key}"), + error: format!("http-client gave invalid header key: {key}"), }); }; let Ok(value) = http::header::HeaderValue::from_str(value) else { return Err(HttpClientError::RequestFailed { - error: format!("http_client gave invalid header value: {value}"), + error: format!("http-client gave invalid header value: {value}"), }); }; headers.insert(key, value); @@ -197,7 +197,7 @@ pub fn open_ws_connection( channel_id: u32, ) -> std::result::Result<(), HttpClientError> { let Ok(Ok(Message::Response { body, .. })) = - KiRequest::to(("our", "http_client", "distro", "sys")) + KiRequest::to(("our", "http-client", "distro", "sys")) .body( serde_json::to_vec(&HttpClientAction::WebSocketOpen { url: url.clone(), @@ -219,7 +219,7 @@ pub fn open_ws_connection( /// Send a WebSocket push message on an open WebSocket channel. pub fn send_ws_client_push(channel_id: u32, message_type: WsMessageType, blob: KiBlob) { - KiRequest::to(("our", "http_client", "distro", "sys")) + KiRequest::to(("our", "http-client", "distro", "sys")) .body( serde_json::to_vec(&HttpClientAction::WebSocketPush { channel_id, @@ -235,7 +235,7 @@ pub fn send_ws_client_push(channel_id: u32, message_type: WsMessageType, blob: K /// Close a WebSocket connection. pub fn close_ws_connection(channel_id: u32) -> std::result::Result<(), HttpClientError> { let Ok(Ok(Message::Response { body, .. })) = - KiRequest::to(("our", "http_client", "distro", "sys")) + KiRequest::to(("our", "http-client", "distro", "sys")) .body( serde_json::json!(HttpClientAction::WebSocketClose { channel_id }) .to_string() diff --git a/src/http/server.rs b/src/http/server.rs index 71aa2e6..3848625 100644 --- a/src/http/server.rs +++ b/src/http/server.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use thiserror::Error; -/// [`crate::Request`] received from the `http_server:distro:sys` service as a +/// [`crate::Request`] received from the `http-server:distro:sys` service as a /// result of either an HTTP or WebSocket binding, created via [`HttpServerAction`]. #[derive(Clone, Debug, Serialize, Deserialize)] pub enum HttpServerRequest { @@ -145,7 +145,7 @@ pub enum WsMessageType { Close, } -/// [`crate::Request`] type sent to `http_server:distro:sys` in order to configure it. +/// [`crate::Request`] type sent to `http-server:distro:sys` in order to configure it. /// /// If a [`crate::Response`] is expected, all actions will return a [`crate::Response`] /// with the shape `Result<(), HttpServerActionError>` serialized to JSON. @@ -209,8 +209,8 @@ pub enum HttpServerAction { desired_reply_type: MessageType, }, /// For communicating with the ext. - /// Kinode's http_server sends this to the ext after receiving [`HttpServerAction::WebSocketExtPushOutgoing`]. - /// Upon receiving reply with this type from ext, http_server parses, setting: + /// Kinode's http-server sends this to the ext after receiving [`HttpServerAction::WebSocketExtPushOutgoing`]. + /// Upon receiving reply with this type from ext, http-server parses, setting: /// * id as given, /// * message type as given ([`crate::Request`] or [`crate::Response`]), /// * body as [`HttpServerRequest::WebSocketPush`], @@ -265,7 +265,7 @@ impl HttpResponse { } } -/// Part of the [`crate::Response`] type issued by http_server +/// Part of the [`crate::Response`] type issued by http-server #[derive(Clone, Debug, Error, Serialize, Deserialize)] pub enum HttpServerError { #[error("request could not be parsed to HttpServerAction: {req}.")] @@ -276,11 +276,11 @@ pub enum HttpServerError { PathBindError { error: String }, #[error("WebSocket error: {error}")] WebSocketPushError { error: String }, - /// Not actually issued by `http_server:distro:sys`, just this library + /// Not actually issued by `http-server:distro:sys`, just this library #[error("timeout")] Timeout, - /// Not actually issued by `http_server:distro:sys`, just this library - #[error("unexpected response from http_server")] + /// Not actually issued by `http-server:distro:sys`, just this library + #[error("unexpected response from http-server")] UnexpectedResponse, } @@ -298,7 +298,7 @@ pub struct HttpServer { ws_paths: HashMap, /// A mapping of WebSocket paths to the channels that are open on them. ws_channels: HashMap>, - /// The timeout given for `http_server:distro:sys` to respond to a configuration request. + /// The timeout given for `http-server:distro:sys` to respond to a configuration request. pub timeout: u64, } @@ -471,7 +471,7 @@ impl HttpServer { { let path: String = path.into(); let cache = config.static_content.is_some(); - let req = KiRequest::to(("our", "http_server", "distro", "sys")).body( + let req = KiRequest::to(("our", "http-server", "distro", "sys")).body( serde_json::to_vec(&if config.secure_subdomain { HttpServerAction::SecureBind { path: path.clone(), @@ -515,7 +515,7 @@ impl HttpServer { T: Into, { let path: String = path.into(); - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body(if config.secure_subdomain { serde_json::to_vec(&HttpServerAction::WebSocketSecureBind { path: path.clone(), @@ -557,7 +557,7 @@ impl HttpServer { T: Into, { let path: String = path.into(); - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body( serde_json::to_vec(&HttpServerAction::Bind { path: path.clone(), @@ -608,7 +608,7 @@ impl HttpServer { T: Into, { let path: String = path.into(); - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body( serde_json::to_vec(&HttpServerAction::SecureBind { path: path.clone(), @@ -650,7 +650,7 @@ impl HttpServer { T: Into, { let path: String = path.into(); - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body( serde_json::to_vec(&HttpServerAction::WebSocketSecureBind { path: path.clone(), @@ -693,7 +693,7 @@ impl HttpServer { .ok_or(HttpServerError::PathBindError { error: "path not found".to_string(), })?; - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body( serde_json::to_vec(&HttpServerAction::Bind { path: path.to_string(), @@ -732,7 +732,7 @@ impl HttpServer { .ok_or(HttpServerError::PathBindError { error: "path not found".to_string(), })?; - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body(if entry.secure_subdomain { serde_json::to_vec(&HttpServerAction::WebSocketSecureBind { path: path.to_string(), @@ -770,7 +770,7 @@ impl HttpServer { T: Into, { let path: String = path.into(); - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body(serde_json::to_vec(&HttpServerAction::Unbind { path: path.clone() }).unwrap()) .send_and_await_response(self.timeout) .unwrap(); @@ -792,7 +792,7 @@ impl HttpServer { T: Into, { let path: String = path.into(); - let res = KiRequest::to(("our", "http_server", "distro", "sys")) + let res = KiRequest::to(("our", "http-server", "distro", "sys")) .body( serde_json::to_vec(&HttpServerAction::WebSocketUnbind { path: path.clone() }) .unwrap(), @@ -889,7 +889,7 @@ impl HttpServer { } /// Serve static files from a given directory by binding all of them - /// in http_server to their filesystem path. + /// in http-server to their filesystem path. /// /// The directory is relative to the `pkg` folder within this package's drive. /// @@ -1045,7 +1045,7 @@ pub fn send_response(status: StatusCode, headers: Option /// Send a WebSocket push message on an open WebSocket channel. pub fn send_ws_push(channel_id: u32, message_type: WsMessageType, blob: KiBlob) { - KiRequest::to(("our", "http_server", "distro", "sys")) + KiRequest::to(("our", "http-server", "distro", "sys")) .body( serde_json::to_vec(&HttpServerRequest::WebSocketPush { channel_id, diff --git a/src/kimap.rs b/src/kimap.rs index a2f96d6..19923c3 100644 --- a/src/kimap.rs +++ b/src/kimap.rs @@ -220,7 +220,7 @@ pub mod contract { } /// A mint log from the kimap, converted to a 'resolved' format using -/// namespace data saved in the kns_indexer. +/// namespace data saved in the kns-indexer. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Mint { pub name: String, @@ -228,7 +228,7 @@ pub struct Mint { } /// A note log from the kimap, converted to a 'resolved' format using -/// namespace data saved in the kns_indexer +/// namespace data saved in the kns-indexer #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Note { pub note: String, @@ -237,7 +237,7 @@ pub struct Note { } /// A fact log from the kimap, converted to a 'resolved' format using -/// namespace data saved in the kns_indexer +/// namespace data saved in the kns-indexer #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Fact { pub fact: String, @@ -255,7 +255,7 @@ pub enum DecodeLogError { InvalidName(String), /// An error occurred while decoding the log. DecodeError(String), - /// The parent name could not be resolved with `kns_indexer`. + /// The parent name could not be resolved with `kns-indexer`. UnresolvedParent(String), } diff --git a/src/lib.rs b/src/lib.rs index 0bc679a..1b1511f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub mod homepage; /// Contains types from the `http` crate to use as well. /// /// Your process must have the [`Capability`] to message and receive messages from -/// `http_server:distro:sys` and/or `http_client:distro:sys` to use this module. +/// `http-server:distro:sys` and/or `http-client:distro:sys` to use this module. pub mod http; /// The types that the kernel itself uses -- warning -- these will /// be incompatible with WIT types in some cases, leading to annoying errors. diff --git a/src/net.rs b/src/net.rs index c8ab253..231320d 100644 --- a/src/net.rs +++ b/src/net.rs @@ -108,7 +108,7 @@ pub enum NetResponse { Verified(bool), } -/// Request performed to `kns_indexer:kns_indexer:sys`, a userspace process +/// Request performed to `kns-indexer:kns-indexer:sys`, a userspace process /// installed by default. /// /// Other requests exist but are only used internally. @@ -131,7 +131,7 @@ pub struct NamehashToNameRequest { pub block: Option, } -/// Response from `kns_indexer:kns_indexer:sys`. +/// Response from `kns-indexer:kns-indexer:sys`. #[derive(Debug, Serialize, Deserialize)] pub enum IndexerResponses { /// Response to [`IndexerRequests::NamehashToName`]. @@ -222,7 +222,7 @@ pub fn get_name(namehash: T, block: Option, timeout: Option) -> Opt where T: Into, { - let res = Request::to(("our", "kns_indexer", "kns_indexer", "sys")) + let res = Request::to(("our", "kns-indexer", "kns-indexer", "sys")) .body( serde_json::to_vec(&IndexerRequests::NamehashToName(NamehashToNameRequest { hash: namehash.into(),