Skip to content

Commit

Permalink
Merge pull request #674 from swimos/rust-1.79
Browse files Browse the repository at this point in the history
Updates for Rust 1.79.0
  • Loading branch information
horned-sphere authored Jun 26, 2024
2 parents f1d3d6d + fd6a084 commit f6d06e0
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 113 deletions.
2 changes: 1 addition & 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.78.0"
latest_version: "1.79.0"

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion api/swimos_form/tests/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ fn annotated() {
let ex = ExampleAnnotated::A {
count: 1033,
name: String::from("bob"),
age: i32::max_value(),
age: i32::MAX,
};

let expected = Value::Record(
Expand Down
28 changes: 8 additions & 20 deletions api/swimos_model/src/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,14 @@ mod tests {

#[test]
fn much_less() {
assert_eq!(cmp_i32_u32(10, u32::max_value()), Ordering::Less);
assert_eq!(cmp_u32_i32(10, i32::max_value()), Ordering::Less);
assert_eq!(cmp_i32_u32(10, u32::MAX), Ordering::Less);
assert_eq!(cmp_u32_i32(10, i32::MAX), Ordering::Less);
}

#[test]
fn much_greater() {
assert_eq!(
cmp_i32_u32(i32::max_value(), u32::min_value()),
Ordering::Greater
);
assert_eq!(
cmp_u32_i32(u32::max_value(), i32::min_value()),
Ordering::Greater
);
assert_eq!(cmp_i32_u32(i32::MAX, u32::MIN), Ordering::Greater);
assert_eq!(cmp_u32_i32(u32::MAX, i32::MIN), Ordering::Greater);
}
}

Expand Down Expand Up @@ -125,20 +119,14 @@ mod tests {

#[test]
fn much_less() {
assert_eq!(cmp_i64_u64(10, u64::max_value()), Ordering::Less);
assert_eq!(cmp_u64_i64(10, i64::max_value()), Ordering::Less);
assert_eq!(cmp_i64_u64(10, u64::MAX), Ordering::Less);
assert_eq!(cmp_u64_i64(10, i64::MAX), Ordering::Less);
}

#[test]
fn much_greater() {
assert_eq!(
cmp_i64_u64(i64::max_value(), u64::min_value()),
Ordering::Greater
);
assert_eq!(
cmp_u64_i64(u64::max_value(), i64::min_value()),
Ordering::Greater
);
assert_eq!(cmp_i64_u64(i64::MAX, u64::MIN), Ordering::Greater);
assert_eq!(cmp_u64_i64(u64::MAX, i64::MIN), Ordering::Greater);
}
}
}
4 changes: 2 additions & 2 deletions runtime/swimos_remote/src/tls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ impl CryptoProviderConfig {
CryptoProviderConfig::FromFeatureFlags => {
#[cfg(all(feature = "ring_provider", not(feature = "aws_lc_rs_provider")))]
{
return Arc::new(rustls::crypto::ring::default_provider());
return Ok(Arc::new(rustls::crypto::ring::default_provider()));
}

#[cfg(all(feature = "aws_lc_rs_provider", not(feature = "ring_provider")))]
{
return Arc::new(rustls::crypto::aws_lc_rs::default_provider());
return Ok(Arc::new(rustls::crypto::aws_lc_rs::default_provider()));
}

#[allow(unreachable_code)]
Expand Down
13 changes: 9 additions & 4 deletions runtime/swimos_runtime/src/agent/task/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ where
http_lane_endpoints,
store_endpoints,
} = endpoints;
let mut initializers: FuturesUnordered<ItemInitTask<'_, Store::StoreId>> =
FuturesUnordered::new();
let mut initializers: FuturesUnordered<ItemInitTask<'_>> = FuturesUnordered::new();
loop {
let event = tokio::select! {
Some(item_init_done) = initializers.next(), if !initializers.is_empty() => Either::Left(item_init_done),
Expand Down Expand Up @@ -502,7 +501,10 @@ where
if let Some(init) =
initialization.add_lane(store, name.clone(), kind, config, promise)
{
initializers.push(init.map_ok(Into::into).boxed());
initializers.push(
init.map_ok(|(endpoint, _)| ItemEndpoint::Lane { endpoint })
.boxed(),
);
}
}
AgentRuntimeRequest::AddStore(StoreRuntimeSpec {
Expand All @@ -515,7 +517,10 @@ where
if let Some(init) =
initialization.add_store(store, name.clone(), kind, config, promise)?
{
initializers.push(init.map_ok(Into::into).boxed());
initializers.push(
init.map_ok(|(endpoint, _)| ItemEndpoint::Store { endpoint })
.boxed(),
);
}
}
AgentRuntimeRequest::OpenDownlink(request) => {
Expand Down
26 changes: 4 additions & 22 deletions runtime/swimos_runtime/src/agent/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,35 +1108,17 @@ struct InactiveTimeout<'a> {
enabled: bool,
}

pub enum ItemEndpoint<I> {
Lane {
endpoint: LaneEndpoint<Io>,
store_id: Option<I>,
},
Store {
endpoint: StoreEndpoint,
store_id: I,
},
}

impl<I> From<(LaneEndpoint<Io>, Option<I>)> for ItemEndpoint<I> {
fn from((endpoint, store_id): (LaneEndpoint<Io>, Option<I>)) -> Self {
ItemEndpoint::Lane { endpoint, store_id }
}
}

impl<I> From<(StoreEndpoint, I)> for ItemEndpoint<I> {
fn from((endpoint, store_id): (StoreEndpoint, I)) -> Self {
ItemEndpoint::Store { endpoint, store_id }
}
pub enum ItemEndpoint {
Lane { endpoint: LaneEndpoint<Io> },
Store { endpoint: StoreEndpoint },
}

type InitResult<T> = Result<T, AgentItemInitError>;

type LaneResult<I> = InitResult<(LaneEndpoint<Io>, Option<I>)>;
type StoreResult<I> = InitResult<(StoreEndpoint, I)>;

type ItemInitTask<'a, I> = BoxFuture<'a, InitResult<ItemEndpoint<I>>>;
type ItemInitTask<'a> = BoxFuture<'a, InitResult<ItemEndpoint>>;

/// Aggregates all of the streams of events for the write task.
#[derive(Debug)]
Expand Down
70 changes: 19 additions & 51 deletions server/swimos_agent_derive/src/agent_lifecycle/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,18 @@ fn validate_method_as<'a>(
})
}
HandlerKind::Command => Validation::join(acc, validate_typed_sig(sig, 1, true))
.and_then(|(mut acc, t)| {
.and_then(|(mut acc, _t)| {
for target in targets {
if let Err(e) = acc.add_on_command(target, t, &sig.ident) {
if let Err(e) = acc.add_on_command(target, &sig.ident) {
return Validation::Validated(acc, Errors::of(e));
}
}
Validation::valid(acc)
}),
HandlerKind::Cue => {
Validation::join(acc, validate_cue_sig(sig)).and_then(|(mut acc, t)| {
Validation::join(acc, validate_cue_sig(sig)).and_then(|(mut acc, _t)| {
for target in targets {
if let Err(e) = acc.add_on_cue(target, t, &sig.ident) {
if let Err(e) = acc.add_on_cue(target, &sig.ident) {
return Validation::Validated(acc, Errors::of(e));
}
}
Expand Down Expand Up @@ -384,9 +384,9 @@ fn validate_method_as<'a>(
Validation::valid(acc)
}),
HandlerKind::JoinMap => Validation::join(acc, validate_join_map_lifecycle_sig(sig))
.and_then(|(mut acc, (l, k, v))| {
.and_then(|(mut acc, (_l, k, v))| {
for target in targets {
if let Err(e) = acc.add_join_map_lifecycle(target, l, k, v, &sig.ident) {
if let Err(e) = acc.add_join_map_lifecycle(target, k, v, &sig.ident) {
return Validation::Validated(acc, Errors::of(e));
}
}
Expand Down Expand Up @@ -1205,7 +1205,7 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
)),
ItemLifecycle::Map(MapLifecycleDescriptor {
name,
join_lifecycle: JoinLifecycle::JoinMap(_, join_lc),
join_lifecycle: JoinLifecycle::JoinMap(join_lc),
..
}) => Some(JoinLaneInit::new(name.clone(), JoinLaneKind::Map, join_lc)),
_ => None,
Expand Down Expand Up @@ -1247,7 +1247,6 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
pub fn add_join_map_lifecycle(
&mut self,
name: String,
link_key_type: &'a Type,
key_type: &'a Type,
value_type: &'a Type,
method: &'a Ident,
Expand All @@ -1257,14 +1256,13 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
} = self;
match lane_lifecycles.get_mut(&name) {
Some(ItemLifecycle::Map(desc)) => {
desc.add_join_map_lifecycle(link_key_type, key_type, value_type, method)
desc.add_join_map_lifecycle(key_type, value_type, method)
}
None => {
lane_lifecycles.insert(
name.clone(),
ItemLifecycle::Map(MapLifecycleDescriptor::new_join_map_lifecycle(
name,
link_key_type,
(key_type, value_type),
method,
)),
Expand Down Expand Up @@ -1316,12 +1314,7 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
}
}

pub fn add_on_command(
&mut self,
name: String,
handler_type: &'a Type,
method: &'a Ident,
) -> Result<(), syn::Error> {
pub fn add_on_command(&mut self, name: String, method: &'a Ident) -> Result<(), syn::Error> {
let AgentLifecycleDescriptorBuilder {
lane_lifecycles, ..
} = self;
Expand Down Expand Up @@ -1368,23 +1361,14 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
_ => {
lane_lifecycles.insert(
name.clone(),
ItemLifecycle::Command(CommandLifecycleDescriptor::new(
name,
handler_type,
method,
)),
ItemLifecycle::Command(CommandLifecycleDescriptor::new(name, method)),
);
Ok(())
}
}
}

pub fn add_on_cue(
&mut self,
name: String,
handler_type: Option<&'a Type>,
method: &'a Ident,
) -> Result<(), syn::Error> {
pub fn add_on_cue(&mut self, name: String, method: &'a Ident) -> Result<(), syn::Error> {
let AgentLifecycleDescriptorBuilder {
lane_lifecycles, ..
} = self;
Expand Down Expand Up @@ -1431,11 +1415,7 @@ impl<'a> AgentLifecycleDescriptorBuilder<'a> {
_ => {
lane_lifecycles.insert(
name.clone(),
ItemLifecycle::Demand(DemandLifecycleDescriptor::new(
name,
handler_type,
method,
)),
ItemLifecycle::Demand(DemandLifecycleDescriptor::new(name, method)),
);
Ok(())
}
Expand Down Expand Up @@ -2208,39 +2188,29 @@ impl<'a> ValueLifecycleDescriptor<'a> {

pub struct CommandLifecycleDescriptor<'a> {
pub name: String, //The name of the lane.
pub primary_lane_type: &'a Type,
pub on_command: &'a Ident,
}

impl<'a> CommandLifecycleDescriptor<'a> {
pub fn new(name: String, primary_lane_type: &'a Type, on_command: &'a Ident) -> Self {
CommandLifecycleDescriptor {
name,
primary_lane_type,
on_command,
}
pub fn new(name: String, on_command: &'a Ident) -> Self {
CommandLifecycleDescriptor { name, on_command }
}
}

pub struct DemandLifecycleDescriptor<'a> {
pub name: String, //The name of the lane.
pub primary_lane_type: Option<&'a Type>,
pub on_cue: &'a Ident,
}

impl<'a> DemandLifecycleDescriptor<'a> {
pub fn new(name: String, primary_lane_type: Option<&'a Type>, on_cue: &'a Ident) -> Self {
DemandLifecycleDescriptor {
name,
primary_lane_type,
on_cue,
}
pub fn new(name: String, on_cue: &'a Ident) -> Self {
DemandLifecycleDescriptor { name, on_cue }
}
}

pub enum JoinLifecycle<'a> {
None,
JoinMap(&'a Type, &'a Ident),
JoinMap(&'a Ident),
JoinValue(&'a Ident),
}

Expand Down Expand Up @@ -2427,7 +2397,6 @@ impl<'a> MapLifecycleDescriptor<'a> {

pub fn new_join_map_lifecycle(
name: String,
link_key_type: &'a Type,
map_type: (&'a Type, &'a Type),
join_lifecycle: &'a Ident,
) -> Self {
Expand All @@ -2438,7 +2407,7 @@ impl<'a> MapLifecycleDescriptor<'a> {
on_update: None,
on_remove: None,
on_clear: None,
join_lifecycle: JoinLifecycle::JoinMap(link_key_type, join_lifecycle),
join_lifecycle: JoinLifecycle::JoinMap(join_lifecycle),
}
}

Expand Down Expand Up @@ -2557,7 +2526,6 @@ impl<'a> MapLifecycleDescriptor<'a> {

pub fn add_join_map_lifecycle(
&mut self,
link_key_type: &'a Type,
key_type: &'a Type,
value_type: &'a Type,
method: &'a Ident,
Expand All @@ -2572,7 +2540,7 @@ impl<'a> MapLifecycleDescriptor<'a> {
let map_type = (key_type, value_type);
match join_lifecycle {
JoinLifecycle::None => {
*join_lifecycle = JoinLifecycle::JoinMap(link_key_type, method);
*join_lifecycle = JoinLifecycle::JoinMap(method);
if map_type != *primary_lane_type {
alternative_lane_types.insert(map_type);
}
Expand Down
5 changes: 2 additions & 3 deletions server/swimos_agent_derive/src/lane_model_derive/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,12 @@ impl<'a> ItemModel<'a> {
let ItemModel {
name,
kind,
flags,
transform,
..
} = self;
kind.lane().map(move |kind| WarpLaneModel {
name,
kind,
flags: *flags,
transform: transform.clone(),
})
}
Expand Down Expand Up @@ -234,7 +233,7 @@ impl<'a> ItemModel<'a> {
pub struct WarpLaneModel<'a> {
pub name: &'a Ident,
pub kind: WarpLaneSpec<'a>,
pub flags: ItemFlags,
//pub flags: ItemFlags,
pub transform: NameTransform,
}

Expand Down
Loading

0 comments on commit f6d06e0

Please sign in to comment.