Skip to content

Commit

Permalink
Compatibility with older Rust versions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherDaniel committed Nov 28, 2023
1 parent 5112ddd commit c6e8bd9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.66.1
7 changes: 3 additions & 4 deletions src/cloudevent/builder/ucloudeventutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ impl UCloudEventUtils {
///
/// Returns `true` if the provided `CloudEvent` is marked with having a platform delivery problem.
pub fn has_communication_problem(event: &Event) -> bool {
UCloudEventUtils::get_communication_status(event)
.is_some_and(|c: i64| c != UCode::Ok as i64)
matches!(UCloudEventUtils::get_communication_status(event), Some(c) if c != UCode::Ok as i64)
}

/// Returns a new `Event` from the supplied `Event`, with the platform communication added.
Expand Down Expand Up @@ -945,7 +944,7 @@ mod tests {
.source("/body.accss//door.front_left#Door")
.data_with_schema(
UCloudEventBuilder::PROTOBUF_CONTENT_TYPE,
format!("proto://{}", any_payload.type_url.clone()),
format!("proto://{}", any_payload.type_url),
any_bytes,
)
.extension("ttl", 3);
Expand Down Expand Up @@ -1065,7 +1064,7 @@ mod tests {
.build()
.unwrap();

let proto_event = CloudEvent::from(source_event.clone());
let proto_event = CloudEvent::from(source_event);
let bytes = proto_event.encode_to_vec();

// Creating the CloudEvent
Expand Down
4 changes: 2 additions & 2 deletions src/proto/cloudevents/protocloudevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl From<CloudEventProto> for cloudevents::Event {
// dataschema
// TODO how is this serialized by eg the Java libraries, considering cloudevent.proto is missing dedicated attributes for this?
if key.eq("dataschema") {
if let Ok(url) = Url::parse(uri) {
if let Ok(url) = Url::parse(uri.as_str()) {
dataschema = Some(url);
}
// if Url::parse() doesn't work, this attribute is lost
Expand Down Expand Up @@ -105,7 +105,7 @@ impl From<CloudEventProto> for cloudevents::Event {
let mut cloud_event = event_builder.build().unwrap();

// Extract data - the proto serialization knows a protobuf.Any type!... something there?
let event_data: Option<Data> = match source_event.data.clone() {
let event_data: Option<Data> = match source_event.data {
Some(CloudEventData::BinaryData(data)) => Some(Data::Binary(data)),
Some(CloudEventData::TextData(text)) => Some(Data::String(text)),
_ => None,
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/rpcmapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ mod tests {
) -> RpcClientResult {
let status = ProtoStatus::from(UStatus::fail_with_code(UCode::InvalidArgument, "boom"));

let any = RpcMapper::pack_any(status.clone()).unwrap();
let any = RpcMapper::pack_any(status).unwrap();
let payload = any.into();

Ok(payload)
Expand All @@ -394,7 +394,7 @@ mod tests {
) -> RpcClientResult {
let status = ProtoStatus::from(UStatus::fail_with_code(UCode::Ok, "all good"));

let any = RpcMapper::pack_any(status.clone()).unwrap();
let any = RpcMapper::pack_any(status).unwrap();
let payload = any.into();

Ok(payload)
Expand Down
2 changes: 1 addition & 1 deletion src/transport/validator/uattributesvalidator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub trait UAttributesValidator {
]
.into_iter()
.filter(|status| status.is_failure())
.map(|status| status.get_message().clone())
.map(|status| status.get_message())
.collect();

let error_message = error_messages.join(", ");
Expand Down

0 comments on commit c6e8bd9

Please sign in to comment.