pub struct GraphBuilder {
    pub label_names_order: LabelNamesOrder,
    /* private fields */
}Expand description
Dynamically builds a small graph in memory
§Examples
§Directories and contents
use swh_graph::swhid;
use swh_graph::graph_builder::GraphBuilder;
use swh_graph::labels::Permission;
let mut builder = GraphBuilder::default();
let a = builder
    .node(swhid!(swh:1:dir:0000000000000000000000000000000000000010)).unwrap()
    .done();
let b = builder
    .node(swhid!(swh:1:dir:0000000000000000000000000000000000000020)).unwrap()
    .done();
let c = builder
    .node(swhid!(swh:1:cnt:0000000000000000000000000000000000000030)).unwrap()
    .done();
builder.dir_arc(a, b, Permission::Directory, b"tests");
builder.dir_arc(a, c, Permission::ExecutableContent, b"run.sh");
builder.dir_arc(b, c, Permission::Content, b"test.c");
let _ = builder.done().unwrap();§Revisions and releases
use swh_graph::swhid;
use swh_graph::graph_builder::GraphBuilder;
let mut builder = GraphBuilder::default();
let a = builder
    .node(swhid!(swh:1:rev:0000000000000000000000000000000000000010)).unwrap()
    .author_timestamp(1708950743, 60)
    .done();
let b = builder
    .node(swhid!(swh:1:rev:0000000000000000000000000000000000000020)).unwrap()
    .committer_timestamp(1708950821, 120)
    .done();
builder.arc(a, b);
let _ = builder.done().unwrap();Fields§
§label_names_order: LabelNamesOrderImplementations§
Source§impl GraphBuilder
 
impl GraphBuilder
Sourcepub fn node(&mut self, swhid: SWHID) -> Result<NodeBuilder<'_>>
 
pub fn node(&mut self, swhid: SWHID) -> Result<NodeBuilder<'_>>
Adds a node to the graph.
Returns Err if there is already a node with this SWHID.
Sourcepub fn node_id(&self, swhid: SWHID) -> Option<NodeId>
 
pub fn node_id(&self, swhid: SWHID) -> Option<NodeId>
Returns NodeId that represents this SWHID in the graph, if it exists
Sourcepub fn dir_arc<P: Into<Permission>, N: Into<Vec<u8>>>(
    &mut self,
    src: NodeId,
    dst: NodeId,
    permission: P,
    name: N,
)
 
pub fn dir_arc<P: Into<Permission>, N: Into<Vec<u8>>>( &mut self, src: NodeId, dst: NodeId, permission: P, name: N, )
Adds a labeled dir->{cnt,dir,rev} arc to the graph
Sourcepub fn snp_arc<N: Into<Vec<u8>>>(&mut self, src: NodeId, dst: NodeId, name: N)
 
pub fn snp_arc<N: Into<Vec<u8>>>(&mut self, src: NodeId, dst: NodeId, name: N)
Adds a labeled snp->{cnt,dir,rev,rel} arc to the graph
Sourcepub fn ori_arc(
    &mut self,
    src: NodeId,
    dst: NodeId,
    status: VisitStatus,
    timestamp: u64,
)
 
pub fn ori_arc( &mut self, src: NodeId, dst: NodeId, status: VisitStatus, timestamp: u64, )
Adds a labeled ori->snp arc to the graph
Sourcepub fn l_arc<L: Into<EdgeLabel>>(&mut self, src: NodeId, dst: NodeId, label: L)
 
pub fn l_arc<L: Into<EdgeLabel>>(&mut self, src: NodeId, dst: NodeId, label: L)
Adds a labeled arc to the graph
pub fn done(&self) -> Result<BuiltGraph>
Trait Implementations§
Source§impl Clone for GraphBuilder
 
impl Clone for GraphBuilder
Source§fn clone(&self) -> GraphBuilder
 
fn clone(&self) -> GraphBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreSource§impl Debug for GraphBuilder
 
impl Debug for GraphBuilder
Source§impl Default for GraphBuilder
 
impl Default for GraphBuilder
Source§fn default() -> GraphBuilder
 
fn default() -> GraphBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for GraphBuilder
impl RefUnwindSafe for GraphBuilder
impl Send for GraphBuilder
impl Sync for GraphBuilder
impl Unpin for GraphBuilder
impl UnwindSafe for GraphBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, U> CastableInto<U> for Twhere
    U: CastableFrom<T>,
 
impl<T, U> CastableInto<U> for Twhere
    U: CastableFrom<T>,
Source§impl<T, U> CastableInto<U> for Twhere
    U: CastableFrom<T>,
 
impl<T, U> CastableInto<U> for Twhere
    U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> DowncastableFrom<T> for T
 
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
 
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T> DowncastableFrom<T> for T
 
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
 
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T, U> DowncastableInto<U> for Twhere
    U: DowncastableFrom<T>,
 
impl<T, U> DowncastableInto<U> for Twhere
    U: DowncastableFrom<T>,
Source§impl<T, U> DowncastableInto<U> for Twhere
    U: DowncastableFrom<T>,
 
impl<T, U> DowncastableInto<U> for Twhere
    U: DowncastableFrom<T>,
Source§impl<T, W> HasTypeWitness<W> for Twhere
    W: MakeTypeWitness<Arg = T>,
    T: ?Sized,
 
impl<T, W> HasTypeWitness<W> for Twhere
    W: MakeTypeWitness<Arg = T>,
    T: ?Sized,
Source§impl<T> Identity for Twhere
    T: ?Sized,
 
impl<T> Identity for Twhere
    T: ?Sized,
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
 
impl<T> Pointable for T
Source§impl<T> UpcastableFrom<T> for T
 
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
 
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.
Source§impl<T> UpcastableFrom<T> for T
 
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
 
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.