Struct dgraph_tonic::Mutation
source · pub struct Mutation {
pub set_json: Vec<u8>,
pub delete_json: Vec<u8>,
pub set_nquads: Vec<u8>,
pub del_nquads: Vec<u8>,
pub set: Vec<NQuad>,
pub del: Vec<NQuad>,
pub cond: String,
pub commit_now: bool,
}
Fields§
§set_json: Vec<u8>
§delete_json: Vec<u8>
§set_nquads: Vec<u8>
§del_nquads: Vec<u8>
§set: Vec<NQuad>
§del: Vec<NQuad>
§cond: String
This is being used for upserts.
commit_now: bool
This field is a duplicate of the one in Request and placed here for convenience.
Implementations§
source§impl Mutation
impl Mutation
sourcepub fn new() -> Self
pub fn new() -> Self
Create new Dgraph Mutation object.
Mutation represent required modification of data in DB. Mutation provides two main ways to set data: JSON and RDF N-Quad. You can choose whichever way is convenient. JSON way has implemented to helper functions.
sourcepub fn set_set_json<T>(&mut self, value: &T) -> Result<(), Error>where
T: Serialize + ?Sized,
pub fn set_set_json<T>(&mut self, value: &T) -> Result<(), Error>where T: Serialize + ?Sized,
Set set JSON data in Mutation.
Arguments
value
- ref to struct which can be serialized into JSON
Errors
Return serde_json:Error when value cannot be serialized to JSON format
Examples
use dgraph_tonic::Mutation;
use serde::Serialize;
#[derive(Serialize)]
struct Person {
uid: String,
name: String,
}
let p = Person {
uid: "_:alice".into(),
name: "Alice".into(),
};
let mut mu = Mutation::new();
mu.set_set_json(&p).expect("JSON");
sourcepub fn set_delete_json<T>(&mut self, value: &T) -> Result<(), Error>where
T: Serialize + ?Sized,
pub fn set_delete_json<T>(&mut self, value: &T) -> Result<(), Error>where T: Serialize + ?Sized,
Set delete JSON data in Mutation.
Arguments
value
- ref to struct which can be serialized into JSON
Errors
Return serde_json:Error when value cannot be serialized to JSON format
Examples
use dgraph_tonic::Mutation;
use serde::Serialize;
#[derive(Serialize)]
struct Person {
uid: String,
name: Option<String>,
}
let p = Person {
uid: "_:0x1".into(),
name: None,
};
let mut mu = Mutation::new();
//remove name predicate
mu.set_delete_json(&p).expect("JSON");
sourcepub fn set_set_nquads<S: Into<String>>(&mut self, nquads: S)
pub fn set_set_nquads<S: Into<String>>(&mut self, nquads: S)
sourcepub fn set_delete_nquads<S: Into<String>>(&mut self, nquads: S)
pub fn set_delete_nquads<S: Into<String>>(&mut self, nquads: S)
Trait Implementations§
source§impl Message for Mutation
impl Message for Mutation
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>where
B: BufMut,
Self: Sized,
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>where B: BufMut, Self: Sized,
Encodes the message to a buffer. Read more
source§fn encode_to_vec(&self) -> Vec<u8, Global>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8, Global>where Self: Sized,
Encodes the message to a newly allocated buffer.
source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>where
B: BufMut,
Self: Sized,
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>where B: BufMut, Self: Sized,
Encodes the message with a length-delimiter to a buffer. Read more
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8, Global>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8, Global>where Self: Sized,
Encodes the message with a length-delimiter to a newly allocated buffer.
source§fn decode<B>(buf: B) -> Result<Self, DecodeError>where
B: Buf,
Self: Default,
fn decode<B>(buf: B) -> Result<Self, DecodeError>where B: Buf, Self: Default,
Decodes an instance of the message from a buffer. Read more
source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>where
B: Buf,
Self: Default,
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>where B: Buf, Self: Default,
Decodes a length-delimited instance of the message from the buffer.
source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>where
B: Buf,
Self: Sized,
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>where B: Buf, Self: Sized,
Decodes an instance of the message from a buffer, and merges it into
self
. Read moresource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>where
B: Buf,
Self: Sized,
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>where B: Buf, Self: Sized,
Decodes a length-delimited instance of the message from buffer, and
merges it into
self
.source§impl PartialEq<Mutation> for Mutation
impl PartialEq<Mutation> for Mutation
impl StructuralPartialEq for Mutation
Auto Trait Implementations§
impl RefUnwindSafe for Mutation
impl Send for Mutation
impl Sync for Mutation
impl Unpin for Mutation
impl UnwindSafe for Mutation
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request