Skip to content

Commit

Permalink
expose generate_message fn as public
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeepee committed Nov 3, 2020
1 parent b46af05 commit c336fbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gremlin-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl GremlinClient {
Ok(GResultSet::new(self.clone(), results, response, conn))
}

pub(crate) fn submit_traversal(&self, bytecode: &Bytecode) -> GremlinResult<GResultSet> {
pub fn generate_message(&self, bytecode: &Bytecode) -> GremlinResult<Message<serde_json::Value>> {
let mut args = HashMap::new();

args.insert(String::from("gremlin"), GValue::Bytecode(bytecode.clone()));
Expand All @@ -150,12 +150,17 @@ impl GremlinClient {

let args = self.options.serializer.write(&GValue::from(args))?;

let message = message_with_args(String::from("bytecode"), String::from("traversal"), args);
Ok(message_with_args(String::from("bytecode"), String::from("traversal"), args))
}

pub(crate) fn submit_traversal(&self, bytecode: &Bytecode) -> GremlinResult<GResultSet> {
let message = self.generate_message(bytecode)?;

let conn = self.pool.get()?;

self.send_message(conn, message)
}

pub(crate) fn read_response(
&self,
conn: &mut r2d2::PooledConnection<GremlinConnectionManager>,
Expand Down
1 change: 1 addition & 0 deletions gremlin-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub use connection::{ConnectionOptions, TlsOptions};
pub use conversion::{BorrowFromGValue, FromGValue, ToGValue};
pub use error::GremlinError;
pub use io::GraphSON;
pub use message::Message;

pub type GremlinResult<T> = Result<T, error::GremlinError>;

Expand Down

0 comments on commit c336fbc

Please sign in to comment.