Skip to content

Commit 50400d4

Browse files
authored
Merge pull request #114 from kinode-dao/hf/add-docs-links
add docs links
2 parents 432d2b7 + d94b517 commit 50400d4

26 files changed

+183
-184
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/eth.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum EthAction {
3434
},
3535
}
3636

37-
/// Incoming `Request` containing subscription updates or errors that processes will receive.
37+
/// Incoming [`crate::Request`] containing subscription updates or errors that processes will receive.
3838
/// Can deserialize all incoming requests from eth:distro:sys to this type.
3939
///
4040
/// Will be serialized and deserialized using `serde_json::to_vec` and `serde_json::from_slice`.
@@ -54,7 +54,7 @@ pub struct EthSubError {
5454
pub error: String,
5555
}
5656

57-
/// The Response type which a process will get from requesting with an [`EthAction`] will be
57+
/// The [`crate::Response`] type which a process will get from requesting with an [`EthAction`] will be
5858
/// of this type, serialized and deserialized using `serde_json::to_vec`
5959
/// and `serde_json::from_slice`.
6060
///
@@ -90,7 +90,7 @@ pub enum EthError {
9090
}
9191

9292
/// The action type used for configuring eth:distro:sys. Only processes which have the "root"
93-
/// capability from eth:distro:sys can successfully send this action.
93+
/// [`crate::Capability`] from eth:distro:sys can successfully send this action.
9494
#[derive(Debug, Serialize, Deserialize)]
9595
pub enum EthConfigAction {
9696
/// Add a new provider to the list of providers.
@@ -126,12 +126,12 @@ pub enum EthConfigAction {
126126
pub enum EthConfigResponse {
127127
Ok,
128128
/// Response from a GetProviders request.
129-
/// Note the [`crate::kernel_types::KnsUpdate`] will only have the correct `name` field.
129+
/// Note the [`crate::net::KnsUpdate`] will only have the correct `name` field.
130130
/// The rest of the Update is not saved in this module.
131131
Providers(SavedConfigs),
132132
/// Response from a GetAccessSettings request.
133133
AccessSettings(AccessSettings),
134-
/// Permission denied due to missing capability
134+
/// Permission denied due to missing [`crate::Capability`]
135135
PermissionDenied,
136136
/// Response from a GetState request
137137
State {
@@ -194,11 +194,11 @@ impl Provider {
194194
request_timeout,
195195
}
196196
}
197-
/// Sends a request based on the specified `EthAction` and parses the response.
197+
/// Sends a request based on the specified [`EthAction`] and parses the response.
198198
///
199-
/// This function constructs a request targeting the Ethereum distribution system, serializes the provided `EthAction`,
199+
/// This function constructs a request targeting the Ethereum distribution system, serializes the provided [`EthAction`],
200200
/// and sends it. It awaits a response with a specified timeout, then attempts to parse the response into the expected
201-
/// type `T`. This method is generic and can be used for various Ethereum actions by specifying the appropriate `EthAction`
201+
/// type `T`. This method is generic and can be used for various Ethereum actions by specifying the appropriate [`EthAction`]
202202
/// and return type `T`.
203203
pub fn send_request_and_parse_response<T: serde::de::DeserializeOwned>(
204204
&self,

src/homepage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::Request;
22

33
/// Add a new icon and/or widget to the Kinode homepage. Note that the process calling this
4-
/// function must have the `homepage:homepage:sys` messaging capability.
4+
/// function must have the `homepage:homepage:sys` messaging [`crate::Capability`].
55
///
66
/// This should be called upon process startup to ensure that the process is added to the homepage.
77
///
@@ -30,7 +30,7 @@ pub fn add_to_homepage(label: &str, icon: Option<&str>, path: Option<&str>, widg
3030
}
3131

3232
/// Remove the caller process from the Kinode homepage. Note that the process calling this function
33-
/// must have the `homepage:homepage:sys` messaging capability.
33+
/// must have the `homepage:homepage:sys` messaging [`crate::Capability`].
3434
///
3535
/// This usually isn't necessary as processes are not persisted on homepage between boots.
3636
pub fn remove_from_homepage() {

src/http/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use std::collections::HashMap;
66
use std::str::FromStr;
77
use thiserror::Error;
88

9-
/// Request type sent to the `http_client:distro:sys` service in order to open a
9+
/// [`crate::Request`] type sent to the `http_client:distro:sys` service in order to open a
1010
/// WebSocket connection, send a WebSocket message on an existing connection, or
1111
/// send an HTTP request.
1212
///
13-
/// You will receive a Response with the format `Result<HttpClientResponse, HttpClientError>`.
13+
/// You will receive a [`crate::Response`] with the format `Result<HttpClientResponse, HttpClientError>`.
1414
///
1515
/// Always serialized/deserialized as JSON.
1616
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -47,7 +47,7 @@ pub struct OutgoingHttpRequest {
4747
pub headers: HashMap<String, String>,
4848
}
4949

50-
/// Request that comes from an open WebSocket client connection in the
50+
/// [`crate::Request`] that comes from an open WebSocket client connection in the
5151
/// `http_client:distro:sys` service. Be prepared to receive these after
5252
/// using a [`HttpClientAction::WebSocketOpen`] to open a connection.
5353
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
@@ -61,7 +61,7 @@ pub enum HttpClientRequest {
6161
},
6262
}
6363

64-
/// Response type received from the `http_client:distro:sys` service after
64+
/// [`crate::Response`] type received from the `http_client:distro:sys` service after
6565
/// sending a successful [`HttpClientAction`] to it.
6666
#[derive(Debug, Serialize, Deserialize)]
6767
pub enum HttpClientResponse {
@@ -125,7 +125,7 @@ pub fn send_request(
125125

126126
/// Make an HTTP request using http_client and await its response.
127127
///
128-
/// Returns [`Response`] from the `http` crate if successful, with the body type as bytes.
128+
/// Returns HTTP response from the `http` crate if successful, with the body type as bytes.
129129
pub fn send_request_await_response(
130130
method: Method,
131131
url: url::Url,

src/http/server.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ use serde::{Deserialize, Serialize};
88
use std::collections::{HashMap, HashSet};
99
use thiserror::Error;
1010

11-
/// HTTP Request received from the `http_server:distro:sys` service as a
11+
/// [`crate::Request`] received from the `http_server:distro:sys` service as a
1212
/// result of either an HTTP or WebSocket binding, created via [`HttpServerAction`].
1313
#[derive(Clone, Debug, Serialize, Deserialize)]
1414
pub enum HttpServerRequest {
1515
Http(IncomingHttpRequest),
1616
/// Processes will receive this kind of request when a client connects to them.
17-
/// If a process does not want this websocket open, they should issue a *request*
17+
/// If a process does not want this websocket open, they should issue a [`crate::Request`]
1818
/// containing a [`HttpServerAction::WebSocketClose`] message and this channel ID.
1919
WebSocketOpen {
2020
path: String,
2121
channel_id: u32,
2222
},
23-
/// Processes can both SEND and RECEIVE this kind of request
23+
/// Processes can both SEND and RECEIVE this kind of [`crate::Request`]
2424
/// (send as [`HttpServerAction::WebSocketPush`]).
25-
/// When received, will contain the message bytes as lazy_load_blob.
25+
/// When received, will contain the message bytes as [`crate::LazyLoadBlob`].
2626
WebSocketPush {
2727
channel_id: u32,
2828
message_type: WsMessageType,
@@ -33,7 +33,7 @@ pub enum HttpServerRequest {
3333
}
3434

3535
impl HttpServerRequest {
36-
/// Parse a byte slice into an HttpServerRequest.
36+
/// Parse a byte slice into an [`HttpServerRequest`].
3737
pub fn from_bytes(bytes: &[u8]) -> serde_json::Result<Self> {
3838
serde_json::from_slice(bytes)
3939
}
@@ -132,9 +132,9 @@ impl IncomingHttpRequest {
132132

133133
/// The possible message types for [`HttpServerRequest::WebSocketPush`].
134134
/// Ping and Pong are limited to 125 bytes by the WebSockets protocol.
135-
/// Text will be sent as a Text frame, with the lazy_load_blob bytes
135+
/// Text will be sent as a Text frame, with the [`crate::LazyLoadBlob`] bytes
136136
/// being the UTF-8 encoding of the string. Binary will be sent as a
137-
/// Binary frame containing the unmodified lazy_load_blob bytes.
137+
/// Binary frame containing the unmodified [`crate::LazyLoadBlob`] bytes.
138138
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
139139
pub enum WsMessageType {
140140
Text,
@@ -144,26 +144,26 @@ pub enum WsMessageType {
144144
Close,
145145
}
146146

147-
/// Request type sent to `http_server:distro:sys` in order to configure it.
147+
/// [`crate::Request`] type sent to `http_server:distro:sys` in order to configure it.
148148
///
149-
/// If a response is expected, all actions will return a Response
149+
/// If a [`crate::Response`] is expected, all actions will return a [`crate::Response`]
150150
/// with the shape `Result<(), HttpServerActionError>` serialized to JSON.
151151
#[derive(Clone, Debug, Serialize, Deserialize)]
152152
pub enum HttpServerAction {
153-
/// Bind expects a lazy_load_blob if and only if `cache` is TRUE. The lazy_load_blob should
154-
/// be the static file to serve at this path.
153+
/// Bind expects a [`crate::LazyLoadBlob`] if and only if `cache` is TRUE.
154+
/// The [`crate::LazyLoadBlob`] should be the static file to serve at this path.
155155
Bind {
156156
path: String,
157157
/// Set whether the HTTP request needs a valid login cookie, AKA, whether
158158
/// the user needs to be logged in to access this path.
159159
authenticated: bool,
160-
/// Set whether requests can be fielded from anywhere, or only the loopback address.
160+
/// Set whether [`crate::Request`]s can be fielded from anywhere, or only the loopback address.
161161
local_only: bool,
162-
/// Set whether to bind the lazy_load_blob statically to this path. That is, take the
163-
/// lazy_load_blob bytes and serve them as the response to any request to this path.
162+
/// Set whether to bind the [`crate::LazyLoadBlob`] statically to this path. That is, take the
163+
/// [`crate::LazyLoadBlob`] bytes and serve them as the response to any request to this path.
164164
cache: bool,
165165
},
166-
/// SecureBind expects a lazy_load_blob if and only if `cache` is TRUE. The lazy_load_blob should
166+
/// SecureBind expects a [`crate::LazyLoadBlob`] if and only if `cache` is TRUE. The [`crate::LazyLoadBlob`] should
167167
/// be the static file to serve at this path.
168168
///
169169
/// SecureBind is the same as Bind, except that it forces requests to be made from
@@ -174,8 +174,8 @@ pub enum HttpServerAction {
174174
/// will require the user to be logged in separately to the general domain authentication.
175175
SecureBind {
176176
path: String,
177-
/// Set whether to bind the lazy_load_blob statically to this path. That is, take the
178-
/// lazy_load_blob bytes and serve them as the response to any request to this path.
177+
/// Set whether to bind the [`crate::LazyLoadBlob`] statically to this path. That is, take the
178+
/// [`crate::LazyLoadBlob`] bytes and serve them as the response to any request to this path.
179179
cache: bool,
180180
},
181181
/// Unbind a previously-bound HTTP path
@@ -199,26 +199,26 @@ pub enum HttpServerAction {
199199
},
200200
/// Unbind a previously-bound WebSocket path
201201
WebSocketUnbind { path: String },
202-
/// When sent, expects a lazy_load_blob containing the WebSocket message bytes to send.
202+
/// When sent, expects a [`crate::LazyLoadBlob`] containing the WebSocket message bytes to send.
203203
WebSocketPush {
204204
channel_id: u32,
205205
message_type: WsMessageType,
206206
},
207-
/// When sent, expects a `lazy_load_blob` containing the WebSocket message bytes to send.
208-
/// Modifies the `lazy_load_blob` by placing into `WebSocketExtPushData` with id taken from
209-
/// this `KernelMessage` and `kinode_message_type` set to `desired_reply_type`.
207+
/// When sent, expects a [`crate::LazyLoadBlob`] containing the WebSocket message bytes to send.
208+
/// Modifies the [`crate::LazyLoadBlob`] by placing into [`HttpServerAction::WebSocketExtPushData`]` with id taken from
209+
/// this [`KernelMessage`]` and `kinode_message_type` set to `desired_reply_type`.
210210
WebSocketExtPushOutgoing {
211211
channel_id: u32,
212212
message_type: WsMessageType,
213213
desired_reply_type: MessageType,
214214
},
215215
/// For communicating with the ext.
216-
/// Kinode's http_server sends this to the ext after receiving `WebSocketExtPushOutgoing`.
216+
/// Kinode's http_server sends this to the ext after receiving [`HttpServerAction::WebSocketExtPushOutgoing`].
217217
/// Upon receiving reply with this type from ext, http_server parses, setting:
218218
/// * id as given,
219-
/// * message type as given (Request or Response),
220-
/// * body as HttpServerRequest::WebSocketPush,
221-
/// * blob as given.
219+
/// * message type as given ([`crate::Request`] or [`crate::Response`]),
220+
/// * body as [`HttpServerRequest::WebSocketPush`],
221+
/// * [`crate::LazyLoadBlob`] as given.
222222
WebSocketExtPushData {
223223
id: u64,
224224
kinode_message_type: MessageType,
@@ -230,11 +230,12 @@ pub enum HttpServerAction {
230230

231231
/// HTTP Response type that can be shared over Wasm boundary to apps.
232232
/// Respond to [`IncomingHttpRequest`] with this type.
233+
///
234+
/// BODY is stored in the [`crate::LazyLoadBlob`] as bytes
233235
#[derive(Clone, Debug, Serialize, Deserialize)]
234236
pub struct HttpResponse {
235237
pub status: u16,
236238
pub headers: HashMap<String, String>,
237-
// BODY is stored in the lazy_load_blob, as bytes
238239
}
239240

240241
impl HttpResponse {
@@ -268,7 +269,7 @@ impl HttpResponse {
268269
}
269270
}
270271

271-
/// Part of the Response type issued by http_server
272+
/// Part of the [`crate::Response`] type issued by http_server
272273
#[derive(Clone, Debug, Error, Serialize, Deserialize)]
273274
pub enum HttpServerError {
274275
#[error("request could not be parsed to HttpServerAction: {req}.")]
@@ -287,7 +288,7 @@ pub enum HttpServerError {
287288
UnexpectedResponse,
288289
}
289290

290-
/// Whether the WebSocketPush is a request or a response.
291+
/// Whether the [`HttpServerAction::WebSocketPush`] is [`crate::Request`] or [`crate::Response`].
291292
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
292293
pub enum MessageType {
293294
Request,

src/kernel_types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub enum KernelCommand {
147147
/// The process that sends this command will be given messaging capabilities
148148
/// for the new process if `public` is false.
149149
///
150-
/// All capabilities passed into initial_capabilities must be held by the source
150+
/// All capabilities passed into `initial_capabilities` must be held by the source
151151
/// of this message, or the kernel will discard them (silently for now).
152152
InitializeProcess {
153153
id: ProcessId,
@@ -273,7 +273,7 @@ impl StateError {
273273
/// - `image`: An optional field containing a URL to an image representing the package.
274274
/// - `external_url`: An optional field containing a URL for more information about the package. For example, a link to the github repository.
275275
/// - `animation_url`: An optional field containing a URL to an animation or video representing the package.
276-
/// - `properties`: A requried field containing important information about the package.
276+
/// - `properties`: A required field containing important information about the package.
277277
#[derive(Clone, Debug, Serialize, Deserialize)]
278278
pub struct Erc721Metadata {
279279
pub name: Option<String>,
@@ -288,15 +288,15 @@ pub struct Erc721Metadata {
288288
/// This follows the [ERC1155](https://github.com/ethereum/ercs/blob/master/ERCS/erc-1155.md#erc-1155-metadata-uri-json-schema) metadata standard.
289289
///
290290
/// Fields:
291-
/// - `package_name`: The unique name of the package, used in the `PackageId`, e.g. `package_name:publisher`.
292-
/// - `publisher`: The KNS identity of the package publisher used in the `PackageId`, e.g. `package_name:publisher`
291+
/// - `package_name`: The unique name of the package, used in the [`crate::PackageId`], e.g. `package_name:publisher`.
292+
/// - `publisher`: The KNS identity of the package publisher used in the [`crate::PackageId`], e.g. `package_name:publisher`
293293
/// - `current_version`: A string representing the current version of the package, e.g. `1.0.0`.
294294
/// - `mirrors`: A list of NodeIds where the package can be found, providing redundancy.
295295
/// - `code_hashes`: A map from version names to their respective SHA-256 hashes.
296296
/// - `license`: An optional field containing the license of the package.
297297
/// - `screenshots`: An optional field containing a list of URLs to screenshots of the package.
298298
/// - `wit_version`: An optional field containing the version of the WIT standard that the package adheres to.
299-
/// - `dependencies`: An optional field containing a list of `PackageId`s: API dependencies.
299+
/// - `dependencies`: An optional field containing a list of [`crate::PackageId`]s: API dependencies.
300300
/// - `api_includes`: An optional field containing a list of `PathBuf`s: additional files to include in the `api.zip`.
301301
#[derive(Clone, Debug, Serialize, Deserialize)]
302302
pub struct Erc721Properties {

src/kimap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pub struct Fact {
246246
}
247247

248248
/// Errors that can occur when decoding a log from the kimap using
249-
/// [`decode_mint_log`] or [`decode_note_log`].
249+
/// [`decode_mint_log()`] or [`decode_note_log()`].
250250
#[derive(Clone, Debug, Deserialize, Serialize)]
251251
pub enum DecodeLogError {
252252
/// The log's topic is not a mint or note event.
@@ -323,7 +323,7 @@ pub fn namehash(name: &str) -> String {
323323

324324
/// Decode a mint log from the kimap into a 'resolved' format.
325325
///
326-
/// Uses `valid_name` to check if the name is valid.
326+
/// Uses [`valid_name()`] to check if the name is valid.
327327
pub fn decode_mint_log(log: &crate::eth::Log) -> Result<Mint, DecodeLogError> {
328328
let contract::Note::SIGNATURE_HASH = log.topics()[0] else {
329329
return Err(DecodeLogError::UnexpectedTopic(log.topics()[0]));
@@ -342,7 +342,7 @@ pub fn decode_mint_log(log: &crate::eth::Log) -> Result<Mint, DecodeLogError> {
342342

343343
/// Decode a note log from the kimap into a 'resolved' format.
344344
///
345-
/// Uses `valid_name` to check if the name is valid.
345+
/// Uses [`valid_name()`] to check if the name is valid.
346346
pub fn decode_note_log(log: &crate::eth::Log) -> Result<Note, DecodeLogError> {
347347
let contract::Note::SIGNATURE_HASH = log.topics()[0] else {
348348
return Err(DecodeLogError::UnexpectedTopic(log.topics()[0]));
@@ -393,7 +393,7 @@ pub fn resolve_parent(log: &crate::eth::Log, timeout: Option<u64>) -> Option<Str
393393
/// Given a [`crate::eth::Log`] (which must be a log from kimap), resolve the full name
394394
/// of the new entry or note.
395395
///
396-
/// Uses `valid_name` to check if the name is valid.
396+
/// Uses [`valid_name()`] to check if the name is valid.
397397
pub fn resolve_full_name(log: &crate::eth::Log, timeout: Option<u64>) -> Option<String> {
398398
let parent_hash = log.topics()[1].to_string();
399399
let parent_name = net::get_name(&parent_hash, log.block_number, timeout)?;

src/kv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
33
use std::marker::PhantomData;
44
use thiserror::Error;
55

6-
/// Actions are sent to a specific key value database, "db" is the name,
7-
/// "package_id" is the package. Capabilities are checked, you can access another process's
8-
/// database if it has given you the capability.
6+
/// Actions are sent to a specific key value database, `db` is the name,
7+
/// `package_id` is the [`PackageId`]. Capabilities are checked, you can access another process's
8+
/// database if it has given you the [`crate::Capability`].
99
#[derive(Debug, Serialize, Deserialize)]
1010
pub struct KvRequest {
1111
pub package_id: PackageId,
@@ -52,7 +52,7 @@ pub enum KvError {
5252
}
5353

5454
/// Kv helper struct for a db.
55-
/// Opening or creating a kv will give you a Result<Kv>.
55+
/// Opening or creating a kv will give you a `Result<Kv>`.
5656
/// You can call it's impl functions to interact with it.
5757
#[derive(Debug, Clone, Serialize, Deserialize)]
5858
pub struct Kv<K, V> {

0 commit comments

Comments
 (0)