Skip to content

Commit

Permalink
Merge pull request #66 from samouwow/run-cargo-fix
Browse files Browse the repository at this point in the history
Ran cargo fix to remove majority of warnings.
  • Loading branch information
besok authored Jun 4, 2024
2 parents ba8180b + 35c52ec commit 6c81378
Show file tree
Hide file tree
Showing 51 changed files with 168 additions and 168 deletions.
8 changes: 4 additions & 4 deletions src/converter.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pub mod to_nav;
pub mod from_nav;

use crate::runtime::rtree::rnode::{RNode, RNodeId};
use crate::runtime::rtree::RuntimeTree;
use crate::runtime::{RtOk, RtResult};
use crate::tree::project::Project;


use crate::runtime::{RtResult};



/// The trait is a simple and generic converter interface. Predominantly is used to handle runtime tree.
Expand Down
12 changes: 6 additions & 6 deletions src/converter/from_nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use quick_xml::events::{BytesStart, Event};
use quick_xml::reader::Reader;
use crate::converter::Converter;
use crate::read_file;
use crate::runtime::rtree::builder::{RtNodeBuilder, RtTreeBuilder};
use crate::runtime::rtree::RuntimeTree;


use crate::runtime::{RtResult, RuntimeError};
use crate::runtime::args::{RtArgs, RtArgument, RtValue};
use crate::runtime::args::{RtArgument, RtValue};
use crate::runtime::builder::ros_nav::{find_ros_action, RosAction, RosParam};
use crate::runtime::rtree::rnode::RNodeName;

use crate::tree::parser::ast::arg::MesType;
use crate::tree::project::Project;


#[cfg(windows)]
const LINE_ENDING: &'static str = "\r\n";
Expand Down Expand Up @@ -50,7 +50,7 @@ impl Converter for FromNav2 {
let mut reader = self.reader();
let mut res = String::new();
// let mut stack = Vec::new();
let mut indent = 0;
let indent = 0;
loop {
match reader.read_event() {
Ok(Event::Eof) => break,
Expand Down
14 changes: 7 additions & 7 deletions src/converter/to_nav.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::collections::{HashMap, HashSet};

use std::fs::File;
use std::io::{Cursor, LineWriter, Write};
use std::path::{Path, PathBuf};
use std::io::{LineWriter};
use std::path::{PathBuf};
use quick_xml::events::{BytesEnd, BytesStart, Event};
use quick_xml::Writer;
use crate::converter::{Converter};
use crate::runtime::rtree::RuntimeTree;
use crate::runtime::{RtOk, RtResult, RuntimeError};
use crate::runtime::args::{RtArgument, RtValue};
use crate::runtime::builder::ros_nav::{find_ros_action, RosAction};
use crate::runtime::builder::ros_nav::{find_ros_action};
use crate::runtime::rtree::rnode::{DecoratorType, FlowType, RNode, RNodeId};

enum State {
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<'a> ToRosNavConverter<'a> {
Self { tree, xml }
}
/// Write the terminal node into the specific format. The terminal node is the node that has no children by contract (actions)
fn write_terminal(&self, w: &mut Writer<LineWriter<File>>, id: RNodeId, node: &RNode) -> RtOk {
fn write_terminal(&self, w: &mut Writer<LineWriter<File>>, _id: RNodeId, node: &RNode) -> RtOk {
let action = node.name()
.and_then(|n| n.name().ok())
.and_then(|name| find_ros_action(name))
Expand All @@ -71,7 +71,7 @@ impl<'a> ToRosNavConverter<'a> {
}
// Write the opening for an interior node into the specific format.
/// The interior node is the node that has children by contract (flows)
fn write_interior_start(&self, w: &mut Writer<LineWriter<File>>, id: RNodeId, node: &RNode) -> RtOk {
fn write_interior_start(&self, w: &mut Writer<LineWriter<File>>, _id: RNodeId, node: &RNode) -> RtOk {
match node {
RNode::Flow(FlowType::Root, n, _, _) => {
let mut root = BytesStart::new("root");
Expand Down Expand Up @@ -130,7 +130,7 @@ impl<'a> ToRosNavConverter<'a> {
Ok(())
}
/// Write the closing for an interior node into the specific format.
fn write_interior_end(&self, w: &mut Writer<LineWriter<File>>, id: RNodeId, node: &RNode) -> RtOk {
fn write_interior_end(&self, w: &mut Writer<LineWriter<File>>, _id: RNodeId, node: &RNode) -> RtOk {
match node {
RNode::Flow(FlowType::Root, _, _, _) => {
w.write_event(Event::End(BytesEnd::new("BehaviorTree")))?;
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/action/builtin/daemon.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::runtime::action::{Impl, recover, Tick};
use crate::runtime::action::{Impl, Tick};
use crate::runtime::args::RtArgs;
use crate::runtime::context::TreeContextRef;
use crate::runtime::{RuntimeError, TickResult};
use crate::runtime::RuntimeError::RecoveryToFailure;

use crate::tracer::Event;


Expand Down
10 changes: 5 additions & 5 deletions src/runtime/action/builtin/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ mod tests {
use crate::runtime::action::Impl;
use crate::runtime::args::{RtArgs, RtArgument, RtValue};
use crate::runtime::blackboard::{BBValue, BlackBoard};
use crate::runtime::context::{TreeContext, TreeContextRef};
use crate::runtime::context::{TreeContextRef};
use crate::runtime::trimmer::TrimmingQueue;
use crate::runtime::{RuntimeError, TickResult};
use crate::tracer::Tracer;
use log::Level::Trace;
use std::collections::HashMap;


use std::sync::{Arc, Mutex};
use crate::runtime::env::RtEnv;

#[test]
fn lock_unlock() {
let mut lock_action = LockUnlockBBKey::Lock;
let lock_action = LockUnlockBBKey::Lock;

let r = lock_action.tick(
RtArgs(vec![RtArgument::new(
Expand Down Expand Up @@ -298,7 +298,7 @@ mod tests {

#[test]
fn store_tick() {
let mut store_tick = super::StoreTick;
let store_tick = super::StoreTick;

let bb = Arc::new(Mutex::new(BlackBoard::default()));

Expand Down
6 changes: 3 additions & 3 deletions src/runtime/action/builtin/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod tests {
use crate::runtime::trimmer::TrimmingQueue;
use crate::runtime::TickResult;
use crate::tracer::Tracer;
use itertools::Itertools;

use std::sync::{Arc, Mutex};
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
Expand All @@ -74,7 +74,7 @@ mod tests {
let port = env.runtime.block_on(async {
let mock_server = MockServer::start().await;

let mut resp = ResponseTemplate::new(200);
let resp = ResponseTemplate::new(200);
let resp = resp.set_body_string("OK");

Mock::given(method("GET"))
Expand All @@ -85,7 +85,7 @@ mod tests {
mock_server.address().port()
});

let mut action = HttpGet;
let action = HttpGet;

let bb = Arc::new(Mutex::new(BlackBoard::default()));
let r = action.tick(
Expand Down
14 changes: 7 additions & 7 deletions src/runtime/action/builtin/remote.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::runtime::action::{Impl, ImplRemote, Tick};
use crate::runtime::args::{RtArgs, RtArgument};
use crate::runtime::context::{TreeContextRef, TreeRemoteContextRef};
use crate::runtime::{to_fail, RuntimeError, RuntimeError::*, TickResult};
use hyper::body::HttpBody;
use crate::runtime::context::{TreeRemoteContextRef};
use crate::runtime::{to_fail, TickResult};

use hyper::client::HttpConnector;
use hyper::{body, Body, Client, Method, Request};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -136,12 +136,12 @@ mod tests {

#[test]
fn smoke() {
let mut env = RtEnv::try_new().unwrap();
let env = RtEnv::try_new().unwrap();

let port = env.runtime.block_on(async {
let mock_server = MockServer::start().await;

let mut resp = ResponseTemplate::new(200);
let resp = ResponseTemplate::new(200);
let resp = resp.set_body_json(json!("Success"));

Mock::given(method("POST"))
Expand All @@ -152,9 +152,9 @@ mod tests {
mock_server.address().port()
});

let mut action = RemoteHttpAction::new(format!("http://localhost:{}/action", port));
let action = RemoteHttpAction::new(format!("http://localhost:{}/action", port));

let bb = Arc::new(Mutex::new(BlackBoard::default()));
let _bb = Arc::new(Mutex::new(BlackBoard::default()));
let r = action.tick(RtArgs(vec![]), TreeRemoteContextRef::new(1, port, Arc::new(Mutex::new(env))));

assert_eq!(r, Ok(TickResult::success()));
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use crate::tree::parser::ast::call::Call;
use crate::tree::parser::ast::message::{Message, Number};
use crate::tree::{cerr, TreeError};
use itertools::Itertools;
use serde::de::{Error, MapAccess, SeqAccess, Visitor};
use serde::{Deserialize, Deserializer, Serialize};

use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::{Display, format, Formatter};
use std::fmt::{Display, Formatter};

/// Just a Key class for the arguments that represents the key in BB
pub type RtAKey = String;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/args/transform.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::runtime::args::{RtArgs, RtArgument, RtValue, RtValueNumber};
use crate::runtime::args::{RtArgs, RtArgument, RtValue};
use crate::runtime::rtree::rnode::DecoratorType;
use crate::tree::parser::ast::arg::{
Argument, ArgumentRhs, Arguments, ArgumentsType, Param, Params,
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ pub mod ros_nav;
pub mod ros_core;

use crate::get_pb;
use crate::runtime::action::builtin::remote::RemoteHttpAction;

use crate::runtime::action::keeper::{ActionImpl, ActionKeeper};
use crate::runtime::action::{Action, ActionName, Impl, ImplAsync, ImplRemote};
use crate::runtime::blackboard::BlackBoard;
use crate::runtime::builder::custom_builder::CustomForesterBuilder;
use crate::runtime::builder::file_builder::FileForesterBuilder;
use crate::runtime::builder::text_builder::TextForesterBuilder;
use crate::runtime::env::RtEnv;
use crate::runtime::forester::serv::HttpServ;

use crate::runtime::forester::{serv, Forester};
use crate::runtime::rtree::builder::RtNodeBuilder;
use crate::runtime::rtree::rnode::RNodeId;
use crate::runtime::rtree::{RuntimeTree, RuntimeTreeStarter};
use crate::runtime::{RtOk, RtResult, RuntimeError};
use crate::tracer::Tracer;
use crate::tree::project::{FileName, TreeName};
use serde::Serialize;

use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use crate::runtime::env::daemon::{DaemonFn, DaemonName, Daemon};
use crate::runtime::env::daemon::{DaemonName, Daemon};
use crate::runtime::env::daemon::context::DaemonContext;

/// The builder to create a Forester instance
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/builder/ros_core.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use itertools::Itertools;



use crate::runtime::action::{Action, ActionName};
use crate::runtime::{RtResult, RuntimeError};
use crate::runtime::ros::OneTimeSender;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::runtime::action::Tick;
use crate::runtime::args::{RtArgs, RtValue};
use crate::runtime::blackboard::{BBRef, BlackBoard};
use crate::runtime::env::{RtEnv, RtEnvRef};
use crate::runtime::env::{RtEnvRef};
use crate::runtime::forester::flow::REASON;
use crate::runtime::rtree::rnode::RNodeId;
use crate::runtime::trimmer::{TrimmingQueue, TrimmingQueueRef};
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool;
use itertools::Itertools;
use tokio::runtime::{Builder, Runtime};
use tokio::select;

use tokio::task::JoinError;
use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken;
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/env/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pub mod task;

use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use tokio::sync::oneshot::Receiver;
use std::sync::{Arc};
use std::sync::atomic::{AtomicBool};

use tokio_util::sync::CancellationToken;
use crate::runtime::env::daemon::context::DaemonContext;

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/env/daemon/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl From<TreeContext> for DaemonContext {
}
}
}impl From<TreeContextRef> for DaemonContext {
fn from(mut value: TreeContextRef) -> Self {
fn from(value: TreeContextRef) -> Self {
DaemonContext {
bb: value.bb(),
tracer: value.tracer(),
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/env/daemon/task.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::sync::atomic::Ordering::Relaxed;
use tokio::sync::oneshot::Sender;

use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken;
use crate::runtime::env::daemon::{DaemonName, StopFlag};
use crate::runtime::{RtOk, RuntimeError};
use crate::runtime::{RtOk};

pub enum DaemonTask {
Unnamed(JoinHandle<()>, DaemonStopSignal),
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/forester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::runtime::{trimmer, RtOk, RtResult, RuntimeError};
use crate::tracer::{Event, Tracer};
use log::debug;
use std::sync::{Arc, Mutex};
use tokio::sync::oneshot::Sender;

use tokio::task::JoinHandle;

/// The entry point to process execution.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/forester/decorator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::runtime::args::{RtArgs, RtArgument, RtValue, RtValueNumber};
use crate::runtime::context::{RNodeState, TreeContext, TreeContextRef};
use crate::runtime::context::{RNodeState, TreeContext};
use crate::runtime::forester::flow::{run_with, LEN, REASON};
use crate::runtime::rtree::rnode::DecoratorType;
use crate::runtime::{RtResult, RuntimeError, TickResult};
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/forester/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn monitor(
)))
}
FlowType::Parallel => {
let mut cursor = read_cursor(tick_args.clone())?;
let cursor = read_cursor(tick_args.clone())?;
let new_args = replace_child_state(
tick_args.with(P_CURSOR, RtValue::int(cursor)),
cursor as usize,
Expand Down Expand Up @@ -277,7 +277,7 @@ pub enum FlowDecision {
}

fn replace_child_state(args: RtArgs, idx: usize, v: i64) -> RtArgs {
let mut args = args;
let args = args;
let mut elems = read_children_state(args.clone());
debug!(target:"params in child", "prev : [{args}], idx:{idx}, new state: {v}");
elems[idx] = v;
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/forester/serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod routes;

use crate::runtime::blackboard::BlackBoard;
use crate::runtime::builder::ServerPort;
use crate::tracer::{Event, Tracer};
use crate::tracer::{Tracer};
use axum::routing::{get, post};
use axum::{Json, Router};
use axum::{Router};

use crate::runtime::forester::serv::routes::*;
use crate::runtime::{RtOk, RtResult, RuntimeError};
Expand All @@ -17,7 +17,7 @@ use hyper::{Body, Client};
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use tokio::runtime::Runtime;

use tokio::sync::oneshot::Sender;
use tokio::task::JoinHandle;
use crate::runtime::env::RtEnv;
Expand Down Expand Up @@ -46,7 +46,7 @@ pub struct ServInfo {
}

impl ServInfo {
pub fn stop(mut self) -> Result<(), ()> {
pub fn stop(self) -> Result<(), ()> {
self.stop_cmd.send(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/forester/serv/routes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::runtime::action::builtin::remote::RemoteActionRequest;

use crate::runtime::args::RtValue;
use crate::runtime::forester::serv::{err_handler, CustomEvent, HttpServ};
use crate::runtime::RuntimeError;
Expand Down
Loading

0 comments on commit 6c81378

Please sign in to comment.