Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/swimos/swim-rust
Browse files Browse the repository at this point in the history
  • Loading branch information
SirCipher committed Jul 29, 2024
2 parents 5ece9ef + 2ac5ce6 commit c76810b
Show file tree
Hide file tree
Showing 32 changed files with 367 additions and 303 deletions.
13 changes: 11 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ updates:
directory: "/"
schedule:
interval: "daily"
# ignore:
# - dependency-name: ""
reviewers:
- "SirCipher"
- "horned-sphere"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 0
reviewers:
- "SirCipher"
- "horned-sphere"
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

name: Continuous integration
env:
latest_version: "1.79.0"
latest_version: "1.80.0"

jobs:
test:
Expand Down Expand Up @@ -142,3 +142,19 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

build_uis:
name: Build Example Application UIs
runs-on: ubuntu-latest
strategy:
matrix:
include:
- path: "stocks_simulated/ui"
cmd: "npm install && npm run build"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build UI
run: |
cd ${PWD}/example_apps/${{ matrix.path }}/
${{ matrix.cmd }}
6 changes: 3 additions & 3 deletions api/formats/swimos_msgpack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//! Provides a MessagesPack backend for the Swim serialization system. This consists of two parts:
//!
//! - A function [`read_from_msg_pack`] that will attempt to deserialize any type that implements
//! [`swimos_form::read::StructuralReadable`] from a buffer containing MessagePack data.
//! [`swimos_form::read::StructuralReadable`] from a buffer containing MessagePack data.
//! - The type [`MsgPackInterpreter`] that implements [`swimos_form::write::StructuralWriter`]
//! allowing any type that implements [`swimos_form::write::StructuralWritable`] to be
//! serialized as MessagePack.
//! allowing any type that implements [`swimos_form::write::StructuralWritable`] to be
//! serialized as MessagePack.
//!
//! # Examples
//!
Expand Down
8 changes: 4 additions & 4 deletions api/formats/swimos_msgpack/src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ mod tests;
/// MessagePack string and bin values. Records have the following encoding.
///
/// - Attributes are written as MessagePack map where the keys are strings. If there are no
/// attributes an empty map value is still required.
/// attributes an empty map value is still required.
/// - The items in the body follow the attributes immediately. If the body consists entirely of
/// slots it is written as a map. If the body consists of all value items or a mix of value items
/// and slots it is written as an array. When a slot occurs in an array body it is written as
/// an array of size two.
/// slots it is written as a map. If the body consists of all value items or a mix of value items
/// and slots it is written as an array. When a slot occurs in an array body it is written as
/// an array of size two.
///
/// # Type Parameters
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ pub trait HeaderPeeler<'a>: Clone {
///
/// # Arguments
/// * `name` - The name of the tag. Note that this has a more restrictive lifetime as may
/// have been unescaped by the parser.
/// have been unescaped by the parser.
fn tag(self, name: &str) -> Result<Self, Self::Error>;

/// Feed a slot from the body of the attribute.
///
/// # Arguments
/// * `name` - The name of the slot. Note that this has a more restrictive lifetime as may
/// have been unescaped by the parser.
/// have been unescaped by the parser.
/// * `value` - Span of the input containing the Recon of the value of the slot.
fn feed_header_slot(self, name: &str, value: Span<'a>) -> Result<Self, Self::Error>;

Expand All @@ -70,7 +70,7 @@ pub trait HeaderPeeler<'a>: Clone {
///
/// # Arguments
/// * `body` - The remainder of the input span. Note that this is entirely uninterpreted and
/// so may not contain valid Recon.
/// so may not contain valid Recon.
fn done(self, body: Span<'a>) -> Result<Self::Output, Self::Error>;
}

Expand Down
20 changes: 10 additions & 10 deletions api/swimos_agent_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ pub mod encoding {
/// # The protocol used by the runtime to communicate with downlinks.
///
/// 1) [`crate::DownlinkNotification`] messages are sent by the runtime to downlinks to inform them that the state
/// of the link has changed or a new event has been received.
/// of the link has changed or a new event has been received.
/// 2) [`crate::DownlinkOperation`] messages are sent to the runtime by the downlink to instruct it to send a
/// command to the remote lane.
/// command to the remote lane.
pub mod downlink {
pub use crate::downlink::{
DownlinkNotificationEncoder, DownlinkOperationDecoder, DownlinkOperationEncoder,
Expand All @@ -62,20 +62,20 @@ pub mod encoding {
/// During the initialization phase:
///
/// 1. The runtime sends one or more [`crate::LaneRequest`] commands which transmit
/// the state of the lane to the agent.
/// the state of the lane to the agent.
/// 2. The runtime sends a single [`crate::LaneRequest::InitComplete`] message.
/// 3. The lane responds with the [`crate::LaneResponse::Initialized`] message.
/// 4. Both parties switch to the protocol for the Agent Running phase.
///
/// During the agent running phase:
/// 1) [`crate::LaneRequest::Command`] messages are sent by the runtime to lane to inform the lane of commands
/// received, addressed to that lane. The lane is not require to respond.
/// received, addressed to that lane. The lane is not require to respond.
/// 2) Each time the state of the lane changes (whether in response to a received command or otherwise) it must
/// notify the runtime of the change using [`crate::LaneResponse::StandardEvent`] message.
/// notify the runtime of the change using [`crate::LaneResponse::StandardEvent`] message.
/// 3) [`crate::LaneRequest::Sync`] messages are sent by the runtime to the lane to request its state. The lane
/// must respond with 0 or more [`crate::LaneResponse::SyncEvent`] messages, labelled with the same ID as provided
/// in the request. After all such messages are sent, it must send a [`crate::LaneResponse::Synced`] message with
/// the same ID.
/// must respond with 0 or more [`crate::LaneResponse::SyncEvent`] messages, labelled with the same ID as provided
/// in the request. After all such messages are sent, it must send a [`crate::LaneResponse::Synced`] message with
/// the same ID.
pub mod lane {
pub use crate::lane::{
MapLaneRequestDecoder, MapLaneRequestEncoder, MapLaneResponseDecoder,
Expand Down Expand Up @@ -120,7 +120,7 @@ pub mod encoding {
/// During the initialization phase:
///
/// 1. The runtime sends one or more [`crate::StoreInitMessage`] commands which transmit
/// the state of the item to the agent.
/// the state of the item to the agent.
/// 2. The runtime sends a single [`crate::StoreInitMessage`] `InitComplete` message.
/// 3. The store or lane responds with the [`crate::StoreInitialized`] message.
/// 4. Both parties switch to the protocol for the Agent Running phase.
Expand All @@ -129,7 +129,7 @@ pub mod encoding {
///
/// 1. The runtime does not send messages to the agent and may drop the channel.
/// 2. The store or land sends [`crate::StoreResponse`] messages each time its state
/// changes which are persisted by the runtime.
/// changes which are persisted by the runtime.
pub mod store {

// TODO Non-transient lanes also implicitly contain a store. They should
Expand Down
6 changes: 3 additions & 3 deletions api/swimos_agent_protocol/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ impl<S, T> AdHocCommand<S, T> {
/// * `address` - The target lane for the command.
/// * `command` - The body of the command message.
/// * `overwrite_permitted` - Controls the behaviour of command handling in the case of back-pressure.
/// If this is true, the command maybe be overwritten by a subsequent command to the same target (and so
/// will never be sent). If false, the command will be queued instead. This is a user specifiable parameter
/// in the API.
/// If this is true, the command maybe be overwritten by a subsequent command to the same target (and so
/// will never be sent). If false, the command will be queued instead. This is a user specifiable parameter
/// in the API.
pub fn new(address: Address<S>, command: T, overwrite_permitted: bool) -> Self {
AdHocCommand {
address,
Expand Down
4 changes: 2 additions & 2 deletions api/swimos_api/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub trait AgentContext: Sync {
/// # Arguments
/// * `name` - The name of the lane.
/// * `land_kind` - Kind of the lane, determining the protocol that the runtime uses
/// to communicate with the lane.
/// to communicate with the lane.
/// * `config` - Configuration parameters for the lane.
fn add_lane(
&self,
Expand Down Expand Up @@ -275,7 +275,7 @@ pub trait Agent {
/// * `route_params` - Parameters extracted from the route URI.
/// * `config` - Configuration parameters for the agent.
/// * `context` - Context through which the agent can interact with the runtime. If this is
/// dropped, then the agent will be terminated.
/// dropped, then the agent will be terminated.
fn run(
&self,
route: RouteUri,
Expand Down
6 changes: 3 additions & 3 deletions api/swimos_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//! This crate provides the API for implementing components that can be executed by the SwimOS runtime.
//!
//! - The [`agent`] module contains the [`agent::Agent`] trait that can be implemented to add new kinds of agent
//! to the runtime. The canonical Rust implementation of this trait can be found in the `swimos_agent` crate.
//! to the runtime. The canonical Rust implementation of this trait can be found in the `swimos_agent` crate.
//! - The [`persistence`] module contains the [`persistence::PlanePersistence`] trait that can be implemented
//! to add new storage implementations to allow a Swim server to maintain an external persistent state that can
//! outlive a single execution of the server process.
//! to add new storage implementations to allow a Swim server to maintain an external persistent state that can
//! outlive a single execution of the server process.
pub mod address;
pub mod agent;
Expand Down
2 changes: 1 addition & 1 deletion api/swimos_form/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extern crate swimos_form_derive;
///
/// ## Container attributes
/// - `#[form(tag = "name")]` on `struct`ures will transmute the structure to a value with the
/// provided tag name.
/// provided tag name.
///
/// ```
/// use swimos_model::{Attr, Item, Value};
Expand Down
34 changes: 17 additions & 17 deletions api/swimos_form/src/structural/read/recognizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,12 @@ impl<T, Flds> OrdinalVTable<T, Flds> {

impl<T, Flds> LabelledStructRecognizer<T, Flds> {
/// # Arguments
/// * `tag` - The expected name of the first attribute or an inidcation that it should be used
/// to populate a field.
/// * `tag` - The expected name of the first attribute or an indication that it should be used
/// to populate a field.
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `num_fields` - The total numer of (non-skipped) fields that the recognizer expects.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn new(
tag: TagSpec,
fields: Flds,
Expand All @@ -835,7 +835,7 @@ impl<T, Flds> LabelledStructRecognizer<T, Flds> {
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `num_fields` - The total numer of (non-skipped) fields that the recognizer expects.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn variant(fields: Flds, num_fields: u32, vtable: LabelledVTable<T, Flds>) -> Self {
let (state, index) = if let Some(i) = (vtable.select_index)(LabelledFieldKey::Header) {
(LabelledStructState::Header, i)
Expand All @@ -856,11 +856,11 @@ impl<T, Flds> LabelledStructRecognizer<T, Flds> {
impl<T, Flds> OrdinalStructRecognizer<T, Flds> {
/// # Arguments
/// * `tag` - The expected name of the first attribute or an inidcation that it should be used
/// to populate a field.
/// to populate a field.
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `num_fields` - The total numer of (non-skipped) fields that the recognizer expects.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn new(
tag: TagSpec,
fields: Flds,
Expand All @@ -885,7 +885,7 @@ impl<T, Flds> OrdinalStructRecognizer<T, Flds> {
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `num_fields` - The total numer of (non-skipped) fields that the recognizer expects.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn variant(fields: Flds, num_fields: u32, vtable: OrdinalVTable<T, Flds>) -> Self {
let (state, index) = if let Some(i) = (vtable.select_index)(OrdinalFieldKey::Header) {
(OrdinalStructState::Header, i)
Expand Down Expand Up @@ -1237,7 +1237,7 @@ impl<T, Flds> LabelledNewtypeRecognizer<T, Flds> {
/// # Arguments
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn new(fields: Flds, vtable: LabelledVTable<T, Flds>) -> Self {
LabelledNewtypeRecognizer { fields, vtable }
}
Expand Down Expand Up @@ -1282,7 +1282,7 @@ impl<T, Flds> OrdinalNewtypeRecognizer<T, Flds> {
/// # Arguments
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn new(fields: Flds, vtable: OrdinalVTable<T, Flds>) -> Self {
OrdinalNewtypeRecognizer { fields, vtable }
}
Expand Down Expand Up @@ -1454,12 +1454,12 @@ pub struct DelegateStructRecognizer<T, Flds> {

impl<T, Flds> DelegateStructRecognizer<T, Flds> {
/// # Arguments
/// * `tag` - The expected name of the first attribute or an inidcation that it should be used
/// to populate a field.
/// * `tag` - The expected name of the first attribute or an indication that it should be used
/// to populate a field.
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `num_fields` - The total numer of (non-skipped) fields that the recognizer expects.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn new(
tag: TagSpec,
fields: Flds,
Expand Down Expand Up @@ -1487,7 +1487,7 @@ impl<T, Flds> DelegateStructRecognizer<T, Flds> {
/// * `fields` - The state of the recognizer state machine (specified by the macro).
/// * `num_fields` - The total numer of (non-skipped) fields that the recognizer expects.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
pub fn variant(fields: Flds, num_fields: u32, vtable: OrdinalVTable<T, Flds>) -> Self {
let (state, index) = if let Some(i) = (vtable.select_index)(OrdinalFieldKey::Header) {
(DelegateStructState::Header, i)
Expand Down Expand Up @@ -1704,7 +1704,7 @@ pub struct TaggedEnumRecognizer<Var> {
impl<Var> TaggedEnumRecognizer<Var> {
/// # Arguments
/// * `select_var` - A function that configures the wrapped recognizer to expect the
/// representation of the appropriate variant, based on the name of the tag attribute.
/// representation of the appropriate variant, based on the name of the tag attribute.
pub fn new(select_var: fn(&str) -> Option<Var>) -> Self {
TaggedEnumRecognizer {
select_var,
Expand Down Expand Up @@ -1996,13 +1996,13 @@ where
}

/// # Arguments
/// * `has_body` - Whehter there is a field lifted to be the body of the header.
/// * `has_body` - Whether there is a field lifted to be the body of the header.
/// * `flattened` - Whether the record containing the fields has been flattened into the attribute
/// body (and so does not have explicit record body delimiting).
/// body (and so does not have explicit record body delimiting).
/// * `num_slots` - The number of slots lifted into the header.
/// * `fields` - The state of the recognizer.
/// * `vtable` - Functions that are generated by the macro that determine how incoming events
/// modify the state.
/// modify the state.
impl<T, Flds> HeaderRecognizer<T, Flds> {
pub fn new(
has_body: bool,
Expand Down
4 changes: 2 additions & 2 deletions api/swimos_form/src/structural/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ pub trait HeaderWriter: Sized {
///
/// # Arguments
/// * `kind` - Description of the contents of the body. If an incorrect value is provided,
/// implementations may return an error but should not panic.
/// implementations may return an error but should not panic.
/// * `num_items` - The number of items in the record. If an incorrect number is provided,
/// implementations may return an error but should not panic.
/// implementations may return an error but should not panic.
fn complete_header(
self,
kind: RecordBodyKind,
Expand Down
4 changes: 2 additions & 2 deletions api/swimos_model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
//! 4. UTF-8 Strings, represented as [`Value::Text`].
//! 5. Arrays of bytes (represented as [`Value::Data`]).
//! - A record consisting of an list of attributes ([`Attr`]) and and list of items ([`Item`]). This is
//! represented as [`Value::Record`].
//! represented as [`Value::Record`].
//!
//! An attribute is a labelled (with a UTF-8 String) [`Value`].
//!
//! An item is one of:
//!
//! - A value item which is an instance of [`Value`]. This is represented as [`Item::ValueItem`].
//! - A slot item which is a pair of two [`Value`]s, the first of which is interpreted as a key. This
//! is represented as [`Item::Slot`].
//! is represented as [`Item::Slot`].
//!
//! Note that the attributes and items of a record are always ordered, although the order may not always be
//! significant, for example if a record, consisting only of slots, is used to represent a map.
Expand Down
Loading

0 comments on commit c76810b

Please sign in to comment.