Skip to main content

GraphUpdate

Struct GraphUpdate 

Source
pub struct GraphUpdate<'a> { /* private fields */ }
Expand description

GraphUpdate provides SPARQL Update operations.

SPARQL Update allows modifying RDF graphs using declarative update operations.

§Examples

§Insert data

use crate::graph::{Graph, GraphUpdate};

let graph = Graph::new()?;
let update = GraphUpdate::new(&graph);

// Insert new triples (without INSERT DATA wrapper)
update.insert("<http://example.org/alice> <http://example.org/name> \"Alice\"")?;

§Delete data

use crate::graph::{Graph, GraphUpdate};

let graph = Graph::new()?;
let update = GraphUpdate::new(&graph);

// Delete triples matching a pattern (without DELETE DATA wrapper)
update.delete("<http://example.org/alice> <http://example.org/name> \"Alice\"")?;

§Update with WHERE clause

use ggen_core::graph::{Graph, GraphUpdate};

let graph = Graph::new()?;
let update = GraphUpdate::new(&graph);

// Delete and insert in one operation (DELETE / INSERT / WHERE patterns)
update.update(
    "?s <http://example.org/old> ?o",
    "?s <http://example.org/new> ?o",
    "?s <http://example.org/old> ?o",
)?;

Implementations§

Source§

impl<'a> GraphUpdate<'a>

Source

pub fn new(graph: &'a Graph) -> Self

Create a new GraphUpdate instance for the given graph.

Source

pub fn execute(&self, update: &str) -> Result<()>

Execute a SPARQL Update operation.

Supports all SPARQL 1.1 Update operations:

  • INSERT DATA
  • DELETE DATA
  • DELETE/INSERT (with WHERE)
  • LOAD
  • CLEAR
  • COPY
  • MOVE
  • ADD
§Arguments
  • update - SPARQL Update string
§Errors

Returns an error if:

  • The update syntax is invalid
  • The update cannot be executed
Source

pub fn insert(&self, data: &str) -> Result<()>

Insert data into the graph.

Shorthand for INSERT DATA { ... }.

§Arguments
  • data - SPARQL data block (triples without INSERT DATA wrapper)
§Security

This method constructs SPARQL UPDATE queries. For user-provided data, prefer using type-safe builders from crate::rdf::query_builder.

Source

pub fn delete(&self, data: &str) -> Result<()>

Delete data from the graph.

Shorthand for DELETE DATA { ... }.

§Arguments
  • data - SPARQL data block (triples without DELETE DATA wrapper)
§Security

This method constructs SPARQL UPDATE queries. For user-provided data, prefer using type-safe builders from crate::rdf::query_builder.

Source

pub fn delete_where(&self, pattern: &str) -> Result<()>

Delete triples matching a WHERE pattern.

Shorthand for DELETE WHERE { ... }.

§Arguments
  • pattern - SPARQL WHERE pattern (without DELETE WHERE wrapper)
§Security

This method constructs SPARQL UPDATE queries. For user-provided data, prefer using type-safe builders from crate::rdf::query_builder.

Source

pub fn update( &self, delete_pattern: &str, insert_pattern: &str, where_pattern: &str, ) -> Result<()>

Update data (DELETE + INSERT with WHERE).

Shorthand for DELETE { ... } INSERT { ... } WHERE { ... }.

§Arguments
  • delete_pattern - Pattern to delete
  • insert_pattern - Pattern to insert
  • where_pattern - WHERE clause pattern
Source

pub fn clear(&self) -> Result<()>

Clear the default graph.

Removes all triples from the default graph.

Source

pub fn clear_graph(&self, graph_iri: &str) -> Result<()>

Clear a named graph.

§Arguments
  • graph_iri - IRI of the graph to clear
Source

pub fn clear_all(&self) -> Result<()>

Clear all graphs (default + named).

Source

pub fn load(&self, url: &str) -> Result<()>

Load data from a URL into the default graph.

§Arguments
  • url - URL to load RDF data from
Source

pub fn load_into(&self, url: &str, graph_iri: &str) -> Result<()>

Load data from a URL into a named graph.

§Arguments
  • url - URL to load RDF data from
  • graph_iri - IRI of the target graph
Source

pub fn copy(&self, source: &str, destination: &str) -> Result<()>

Copy all data from source graph to destination graph.

§Arguments
  • source - Source graph IRI
  • destination - Destination graph IRI
Source

pub fn move_graph(&self, source: &str, destination: &str) -> Result<()>

Move all data from source graph to destination graph.

§Arguments
  • source - Source graph IRI
  • destination - Destination graph IRI
Source

pub fn add(&self, source: &str, destination: &str) -> Result<()>

Add all data from source graph to destination graph.

§Arguments
  • source - Source graph IRI
  • destination - Destination graph IRI

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for GraphUpdate<'a>

§

impl<'a> !UnwindSafe for GraphUpdate<'a>

§

impl<'a> Freeze for GraphUpdate<'a>

§

impl<'a> Send for GraphUpdate<'a>

§

impl<'a> Sync for GraphUpdate<'a>

§

impl<'a> Unpin for GraphUpdate<'a>

§

impl<'a> UnsafeUnpin for GraphUpdate<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> EvidenceKind for T

Source§

default fn kind_label(&self) -> &'static str

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more