pub struct TestDag {
pub dag: Dag,
pub seg_size: usize,
pub dir: TempDir,
pub output: Arc<Mutex<Vec<String>>>,
}Expand description
Dag structure for testing purpose.
Fields§
§dag: Dag§seg_size: usize§dir: TempDir§output: Arc<Mutex<Vec<String>>>Implementations§
Source§impl TestDag
impl TestDag
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a TestDag for testing.
Side effect of the TestDag will be removed on drop.
Sourcepub fn draw(text: &str) -> Self
pub fn draw(text: &str) -> Self
Crates a TestDag using the given ASCII.
This is just new, followed by drawdag, with an extra rule that
comments like “# master: M” at the end can be used to specify master
heads .
Sourcepub async fn draw_client(text: &str) -> Self
pub async fn draw_client(text: &str) -> Self
Similar to draw but creates a lazy client so all vertexes
in the master group are lazy.
Sourcepub fn new_with_segment_size(seg_size: usize) -> Self
pub fn new_with_segment_size(seg_size: usize) -> Self
Creates a TestDag with a specific segment size.
Sourcepub fn drawdag(&mut self, text: &str, master_heads: &[&str])
pub fn drawdag(&mut self, text: &str, master_heads: &[&str])
Add vertexes to the graph. Does not resolve vertexes remotely.
Sourcepub async fn drawdag_async(&mut self, text: &str, master_heads: &[&str])
pub async fn drawdag_async(&mut self, text: &str, master_heads: &[&str])
Add vertexes to the graph. Async version that might resolve vertexes remotely on demand.
Sourcepub fn drawdag_with_limited_heads(
&mut self,
text: &str,
master_heads: &[&str],
heads: Option<&[&str]>,
)
pub fn drawdag_with_limited_heads( &mut self, text: &str, master_heads: &[&str], heads: Option<&[&str]>, )
Add vertexes to the graph.
If heads is set, ignore part of the graph. Only consider specified
heads.
pub async fn drawdag_with_limited_heads_async( &mut self, text: &str, master_heads: &[&str], heads: Option<&[&str]>, validate: bool, )
Sourcepub async fn add_one_vertex(&mut self, name: &str, parents: &str)
pub async fn add_one_vertex(&mut self, name: &str, parents: &str)
Add one vertex to the non-master group. parents is split by whitespaces.
Sourcepub fn annotate_ascii(&self, text: &str) -> String
pub fn annotate_ascii(&self, text: &str) -> String
Replace ASCII with Ids in the graph.
Sourcepub fn render_segments(&self) -> String
pub fn render_segments(&self) -> String
Render the segments.
Sourcepub fn render_graph(&self) -> String
pub fn render_graph(&self) -> String
Render the graph.
Sourcepub async fn client(&self) -> TestDag
pub async fn client(&self) -> TestDag
Use this DAG as the “server”, return the “client” Dag that has lazy Vertexes.
Sourcepub fn set_remote(&mut self, server_dag: &Self)
pub fn set_remote(&mut self, server_dag: &Self)
Update remote protocol to use the (updated) server graph.
Sourcepub fn with_remote(self, server_dag: &Self) -> Self
pub fn with_remote(self, server_dag: &Self) -> Self
Alternative syntax of set_remote.
Sourcepub async fn client_cloned_data(&self) -> TestDag
pub async fn client_cloned_data(&self) -> TestDag
Similar to client, but also clone the Dag from the server.
Sourcepub async fn pull_ff_master(
&mut self,
server: &Self,
old_master: impl Into<Set>,
new_master: impl Into<Set>,
) -> Result<()>
pub async fn pull_ff_master( &mut self, server: &Self, old_master: impl Into<Set>, new_master: impl Into<Set>, ) -> Result<()>
Pull from the server Dag using the master fast forward fast path.
Sourcepub async fn export_pull_data(
&self,
common: impl Into<Set>,
heads: impl Into<Set>,
) -> Result<CloneData<Vertex>>
pub async fn export_pull_data( &self, common: impl Into<Set>, heads: impl Into<Set>, ) -> Result<CloneData<Vertex>>
Generate the “pull data”. This is intended to be called from a “server”.
Sourcepub async fn import_pull_data(
&mut self,
pull_data: CloneData<Vertex>,
head_opts: impl Into<VertexListWithOptions>,
) -> Result<()>
pub async fn import_pull_data( &mut self, pull_data: CloneData<Vertex>, head_opts: impl Into<VertexListWithOptions>, ) -> Result<()>
Imports the “pull data”. This is intended to be called from a “client”.
Sourcepub fn remote_protocol(
&self,
output: Arc<Mutex<Vec<String>>>,
) -> Arc<dyn RemoteIdConvertProtocol>
pub fn remote_protocol( &self, output: Arc<Mutex<Vec<String>>>, ) -> Arc<dyn RemoteIdConvertProtocol>
Remote protocol used to resolve Id <-> Vertex remotely using the test dag as the “server”.
Logs of the remote access will be written to output.
Sourcepub fn debug_segments(&self, level: Level, group: Group) -> String
pub fn debug_segments(&self, level: Level, group: Group) -> String
Describe segments at the given level and group as a string.
Sourcepub fn contains_vertex_locally(&self, name: impl Into<Vertex>) -> bool
pub fn contains_vertex_locally(&self, name: impl Into<Vertex>) -> bool
Check that a vertex exists locally.
Methods from Deref<Target = Dag>§
Sourcepub async fn set_managed_virtual_group(
&mut self,
items: Option<Vec<(Vertex, Vec<Vertex>)>>,
) -> Result<()>
pub async fn set_managed_virtual_group( &mut self, items: Option<Vec<(Vertex, Vec<Vertex>)>>, ) -> Result<()>
Set the content of the VIRTUAL group that survives reloading.
items is a list of vertexes and parents. The vertexes MUST be unique
and not already exist in non-VIRTUAL groups. This assumption is used
as an optimization to avoid remote lookups.
Existing content of the VIRTUAL group will be cleared before inserting
items. So this API feels declarative. As a comparison, add_heads
is imperative.
This function calls maybe_recreate_virtual_group immediately to clear
and update contents in the VIRTUAL group. maybe_recreate_virtual_group
will be called automatically after graph changing operations:
add_heads_and_flush, strip, flush, import_pull_data.
Sourcepub fn set_remote_protocol(
&mut self,
protocol: Arc<dyn RemoteIdConvertProtocol>,
)
pub fn set_remote_protocol( &mut self, protocol: Arc<dyn RemoteIdConvertProtocol>, )
Set the remote protocol for converting between Id and Vertex remotely.
This is usually used on “sparse” (“lazy”) Dag where the IdMap is incomplete for vertexes in the master groups.
pub fn dag(&self) -> &IdDag<IS>
pub fn map(&self) -> &M
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TestDag
impl !RefUnwindSafe for TestDag
impl Send for TestDag
impl Sync for TestDag
impl Unpin for TestDag
impl UnsafeUnpin for TestDag
impl !UnwindSafe for TestDag
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
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> 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>
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>
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