Skip to content

Commit

Permalink
Merge pull request #116 from CSML-by-Clevy/chore/rename-memories-struct
Browse files Browse the repository at this point in the history
chore: rename Memories struct to Memory
  • Loading branch information
frsechet authored Sep 23, 2020
2 parents 67e7e27 + cf6b01b commit 049249d
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion csml_engine/src/db_connectors/dynamodb/memories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
encrypt::{decrypt_data, encrypt_data},
Client, ConversationInfo, EngineError,
};
use csml_interpreter::data::Memories as InterpreterMemory;
use csml_interpreter::data::Memory as InterpreterMemory;
use rusoto_dynamodb::*;
use std::collections::HashMap;

Expand Down
2 changes: 1 addition & 1 deletion csml_engine/src/db_connectors/memories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::db_connectors::{dynamodb as dynamodb_connector, is_dynamodb};
#[cfg(feature = "mongo")]
use crate::db_connectors::{is_mongodb, mongodb as mongodb_connector};
use crate::error_messages::ERROR_DB_SETUP;
use crate::{Client, ConversationInfo, Database, EngineError, Memories as Memory};
use crate::{Client, ConversationInfo, Database, EngineError, Memory};

pub fn add_memories(
data: &mut ConversationInfo,
Expand Down
2 changes: 1 addition & 1 deletion csml_engine/src/db_connectors/mongodb/memories.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
db_connectors::mongodb::get_db,
encrypt::{decrypt_data, encrypt_data},
Client, ConversationInfo, EngineError, Memories as Memory,
Client, ConversationInfo, EngineError, Memory,
};
use bson::{doc, Bson};

Expand Down
2 changes: 1 addition & 1 deletion csml_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use interpreter_actions::interpret_step;
use utils::*;

use csml_interpreter::{
data::{csml_bot::CsmlBot, csml_flow::CsmlFlow, ContextJson, Hold, Memories},
data::{csml_bot::CsmlBot, csml_flow::CsmlFlow, ContextJson, Hold, Memory},
load_components,
};
use md5::{Digest, Md5};
Expand Down
4 changes: 2 additions & 2 deletions csml_engine/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
};

use chrono::{prelude::Utc, SecondsFormat};
use csml_interpreter::data::{Client, Event, Memories, Message};
use csml_interpreter::data::{Client, Event, Memory, Message};
use serde_json::{json, map::Map, Value};
use std::env;

Expand All @@ -16,7 +16,7 @@ use std::env;
* Instead, the memory is saved in bulk at the end of each step or interaction, but we still
* must allow the user to use the `remembered` data immediately.
*/
pub fn update_current_context(data: &mut ConversationInfo, mem: &[Memories]) {
pub fn update_current_context(data: &mut ConversationInfo, mem: &[Memory]) {
for elem in mem.iter() {
if let Value::Object(ref mut obj) = data.context.current {
obj.insert(elem.key.to_owned(), elem.value.clone());
Expand Down
2 changes: 1 addition & 1 deletion csml_interpreter/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use event::Event;
pub use fn_args_type::ArgsType;
pub use hold::Hold;
pub use literal::Literal;
pub use memories::{Memories, MemoryType};
pub use memories::{Memory, MemoryType};
pub use message::Message;
pub use message_data::MessageData;

Expand Down
4 changes: 2 additions & 2 deletions csml_interpreter/src/data/memories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ pub enum MemoryType {
}

#[derive(Debug, Clone)]
pub struct Memories {
pub struct Memory {
pub key: String,
pub value: serde_json::Value,
}

impl Memories {
impl Memory {
pub fn new(key: String, value: Literal) -> Self {
let content_type = &value.content_type;
let value = value.primitive.format_mem(content_type, true);
Expand Down
8 changes: 4 additions & 4 deletions csml_interpreter/src/data/message_data.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::data::error_info::ErrorInfo;
use crate::data::{Hold, Literal, Memories, Message, MSG};
use crate::data::{Hold, Literal, Memory, Message, MSG};
use crate::parser::ExitCondition;

use core::ops::Add;
Expand All @@ -11,7 +11,7 @@ use std::sync::mpsc;

#[derive(Debug, Clone)]
pub struct MessageData {
pub memories: Option<Vec<Memories>>,
pub memories: Option<Vec<Memory>>,
pub messages: Vec<Message>,
pub hold: Option<Hold>,
pub exit_condition: Option<ExitCondition>,
Expand Down Expand Up @@ -105,12 +105,12 @@ impl MessageData {
let content_type = &value.content_type;

if let Some(ref mut vec) = self.memories {
vec.push(Memories {
vec.push(Memory {
key: key.to_owned(),
value: value.primitive.format_mem(content_type, true),
});
} else {
self.memories = Some(vec![Memories {
self.memories = Some(vec![Memory {
key: key.to_owned(),
value: value.primitive.format_mem(content_type, true),
}])
Expand Down
4 changes: 2 additions & 2 deletions csml_interpreter/src/data/msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::data::error_info::ErrorInfo;
use crate::data::primitive::PrimitiveNull;
use crate::data::{hold::Hold, message::Message, Literal, Memories, MessageData};
use crate::data::{hold::Hold, message::Message, Literal, Memory, MessageData};

use std::sync::mpsc;

Expand All @@ -10,7 +10,7 @@ use std::sync::mpsc;

#[derive(Debug)]
pub enum MSG {
Memory(Memories),
Memory(Memory),
Message(Message),
Hold(Hold),
Next {
Expand Down
4 changes: 2 additions & 2 deletions csml_interpreter/src/interpreter/ast_interpreter/actions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::data::{
ast::*, literal::ContentType, message::*, primitive::null::PrimitiveNull, Data, Literal,
Memories, MemoryType, MessageData, MSG,
Memory, MemoryType, MessageData, MSG,
};
use crate::error_format::*;
use crate::interpreter::variable_handler::{
Expand Down Expand Up @@ -150,7 +150,7 @@ pub fn match_actions(

MSG::send(
&sender,
MSG::Memory(Memories::new(name.ident.to_owned(), lit.clone())),
MSG::Memory(Memory::new(name.ident.to_owned(), lit.clone())),
);

data.context.current.insert(name.ident.to_owned(), lit);
Expand Down
6 changes: 3 additions & 3 deletions csml_interpreter/src/interpreter/variable_handler/memory.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::data::error_info::ErrorInfo;
use crate::data::position::Position;
use crate::data::{ast::Identifier, Data, Literal, Memories, MemoryType, MessageData, MSG};
use crate::data::{ast::Identifier, Data, Literal, Memory, MemoryType, MessageData, MSG};
use crate::error_format::*;
use std::sync::mpsc;

Expand Down Expand Up @@ -47,15 +47,15 @@ pub fn save_literal_in_mem(
// add value in current mem
MSG::send(
sender,
MSG::Memory(Memories::new(name.clone(), lit.clone())),
MSG::Memory(Memory::new(name.clone(), lit.clone())),
);
data.context.current.insert(name, lit);
}
MemoryType::Use if update => {
data.step_vars.insert(name, lit);
}
_ => {
// TODO: Warning msg element is unmutable ?
// TODO: Warning msg element is immutable ?
// unimplemented!()
}
}
Expand Down

0 comments on commit 049249d

Please sign in to comment.