### Install Binary Dependencies for swh-graph Tests Source: https://docs.rs/swh-graph/latest/swh_graph/index Installs necessary binary dependencies for running Python tests in the swh-graph package, including protobuf-compiler and the Rust toolchain. This is a minimal setup and not recommended for production. ```shell swh-graph$ sudo apt install protobuf-compiler swh-graph$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Breadth-First Traversal Example Source: https://docs.rs/swh-graph/latest/swh_graph/_tutorial/index Demonstrates how to perform a breadth-first traversal of the graph by using a queue instead of a stack. ```APIDOC ## Breadth-First Traversal ### Description This function performs a breadth-first traversal of a graph, starting from a given root node. It uses a queue to manage nodes to visit and a set to keep track of visited nodes. ### Method N/A (Example Function) ### Endpoint N/A (Example Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Prints the visited node IDs to standard output. #### Response Example ``` 123 456 789 ``` ``` -------------------------------- ### Find Directory of Revision Source: https://docs.rs/swh-graph/latest/swh_graph/_tutorial/index An example of finding the target directory of a given revision SWHID by looking up node IDs, types, and successors. ```APIDOC ## Find Target Directory of a Revision ### Description Given a revision's SWHID, this function finds and returns the SWHID of its target directory. It achieves this by converting the SWHID to a node ID, checking its type, iterating through its successors, and returning the SWHID of the first successor that is a directory. ### Method N/A (Example Function) ### Endpoint N/A (Example Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the SWHID of the target directory. #### Response Example ```json { "swhid": "directory_swhid_example" } ``` ``` -------------------------------- ### Initialize SwhUnidirectionalGraph Source: https://docs.rs/swh-graph/latest/swh_graph/graph/index Initializes a new unidirectional Software Heritage graph. This is the starting point for loading graph data incrementally. ```Rust pub fn new() -> Self; ``` -------------------------------- ### Example Usage of swhid Macro (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/macro Demonstrates how to use the swhid macro to create and assert SWHID literals in Rust. It validates that a generated SWHID string matches the expected format. ```Rust use swh_graph::swhid; assert_eq!( swhid!(swh:1:rev:0000000000000000000000000000000000000004).to_string(), "swh:1:rev:0000000000000000000000000000000000000004".to_string(), ); ``` -------------------------------- ### Pointer Initialization and Dereferencing Source: https://docs.rs/swh-graph/latest/swh_graph/struct Provides methods for managing memory via raw pointers. Includes getting alignment, initializing memory with a given initializer, dereferencing (immutable and mutable), and dropping the object at a pointer. ```rust const ALIGN: usize ``` ```rust type Init = T ``` ```rust unsafe fn init(init: ::Init) -> usize ``` ```rust unsafe fn deref<'a>(ptr: usize) -> &'a T ``` ```rust unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ``` ```rust unsafe fn drop(ptr: usize) ``` -------------------------------- ### Rust Example for Loading Graph Properties Source: https://docs.rs/swh-graph/latest/swh_graph/graph_builder/type Demonstrates how to load additional properties into a SwhBidirectionalGraph using the load_properties method. It shows chaining calls to load different types of properties like maps and timestamps. ```rust use swh_graph::java_compat::mph::gov::GOVMPH; use swh_graph::SwhGraphProperties; swh_graph::graph::SwhBidirectionalGraph::new(PathBuf::from("./graph")) .expect("Could not load graph") .init_properties() .load_properties(SwhGraphProperties::load_maps::) .expect("Could not load SWHID maps") .load_properties(SwhGraphProperties::load_timestamps) .expect("Could not load timestamps"); ``` -------------------------------- ### Load and Get Content Length Property (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/_tutorial/index Demonstrates loading the Software Heritage Graph and accessing the 'content length' property for a given blob SWHID. It requires the 'anyhow' and 'swh-graph' crates. The function returns an Option representing the content length or None if unknown. ```rust use std::path::PathBuf; use anyhow::{Result, ensure}; use swh_graph::graph::SwhGraphWithProperties; use swh_graph::mph::DynMphf; use swh_graph::properties; use swh_graph::{NodeType, SWHID}; fn main() { let graph = swh_graph::graph::load_full::(PathBuf::from("./graph")) .unwrap(); let swhid = SWHID::try_from("swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2").unwrap(); println!("Content length: {:?}", get_content_length(&graph, swhid).unwrap()) } fn get_content_length(graph: &G, cnt_swhid: SWHID) -> Result> where G: SwhGraphWithProperties, { let cnt= graph.properties().node_id(cnt_swhid)?; ensure!(graph.properties().node_type(cnt) == NodeType::Content); Ok(graph.properties().content_length(cnt)) // Note this may be None if unknown size } ``` -------------------------------- ### Example: Get Full Name from ID Source: https://docs.rs/swh-graph/latest/swh_graph/person/struct An example function demonstrating how to use `FullnameMap::new` and `map_id` to retrieve an author's full name given their ID and the graph path. It handles potential errors during the process. ```rust use std::path::PathBuf; use anyhow::Error; use swh_graph::person::FullnameMap; fn get_fullname(id: usize, graph_path: PathBuf) -> Result, Error> { Ok(FullnameMap::new(graph_path)?.map_id(id)?.to_owned()) } ``` -------------------------------- ### Print Directory Entries with Labels (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/_tutorial/index This Rust code snippet demonstrates how to load a Software Heritage graph, find a directory node by its SWHID, and iterate through its labeled successors. It specifically extracts and prints directory entry information, including permissions and file names, by decoding the label data. ```rust use swh_graph::mph::DynMphf; use swh_graph::labels::EdgeLabel; let graph = swh_graph::graph::load_full::(PathBuf::from("./graph")) .expect("Could not load graph"); let node_id: usize = graph .properties() .node_id("swh:1:dir:5e1c24e586ef92dbef0e9cec6b354c6831454340") .expect("Unknown SWHID"); for (succ, labels) in graph.labeled_successors(node_id) { for label in labels { if let EdgeLabel::DirEntry(label) = label { println!( "{} -> {} (permission: {:?}; name: {})", node_id, succ, label.permission(), String::from_utf8( graph.properties().label_name(label.filename_id()) ).expect("Could not decode file name as UTF-8") ); } } } ``` -------------------------------- ### Visit Struct Source: https://docs.rs/swh-graph/latest/swh_graph/labels/struct Documentation for the Visit struct, detailing its constructor and available methods. ```APIDOC ## Struct Visit ### Description Represents a visit with a status and a timestamp. ### Constructor ```rust pub fn new(status: VisitStatus, timestamp: u64) -> Option ``` Returns a new `Visit` or `None` if `timestamp` is 2^59 or greater. ### Methods * **`timestamp(&self) -> u64`**: Returns the timestamp of the visit. * **`status(&self) -> VisitStatus`**: Returns the status of the visit. ``` -------------------------------- ### Get TypeId of Self Source: https://docs.rs/swh-graph/latest/swh_graph/compress/zst_dir/struct Gets the `TypeId` of `self`. This is a fundamental method for runtime type reflection. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Get TypeId in Rust Source: https://docs.rs/swh-graph/latest/swh_graph/utils/mmap/struct Provides a method to get the `TypeId` of a given type, useful for runtime type identification. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### GetIndex: get Method Source: https://docs.rs/swh-graph/latest/swh_graph/utils/trait The get method safely retrieves an item from the collection by its index. It returns an Option containing the item if the index is valid, or None otherwise. ```Rust fn get(&self, index: usize) -> Option ``` -------------------------------- ### NumberMmap Implementations Source: https://docs.rs/swh-graph/latest/swh_graph/utils/mmap/struct Contains methods for creating and managing NumberMmap instances, including file-based initialization and length retrieval. ```APIDOC ## impl NumberMmap ### Methods #### `fn new>(path: P, len: usize) -> Result>` Creates a new `NumberMmap` instance from a given file path and length. #### `fn with_file_and_offset>(path: P, len: usize, file: File, offset: usize) -> Result>` Creates a new `NumberMmap` instance using an existing file handle and a specified offset. #### `fn len(&self) -> usize` Returns the total number of elements stored in the `NumberMmap`. ### Example ```rust use std::path::Path; use swh_graph::utils::mmap::NumberMmap; use swh_graph::byte_order::LittleEndian; // Assuming 'example.mmap' exists and contains valid data for u32 integers // let path = Path::new("example.mmap"); // let length = 100; // Number of u32 elements // match NumberMmap::::new(path, length) { // Ok(num_mmap) => { // let count = num_mmap.len(); // println!("NumberMmap contains {} elements.", count); // } // Err(e) => { // eprintln!("Error creating NumberMmap: {}", e); // } // } ``` ``` -------------------------------- ### Create NumberMmap with File and Offset in Rust Source: https://docs.rs/swh-graph/latest/swh_graph/utils/mmap/struct Creates a `NumberMmap` instance using an existing `File` handle and a specified offset within that file. It requires the file path, the desired length of the mapped data, the `File` object, and the starting offset. ```rust pub fn with_file_and_offset>( path: P, len: usize, file: File, offset: usize, ) -> Result> ``` -------------------------------- ### Visit Trait Implementations Source: https://docs.rs/swh-graph/latest/swh_graph/labels/struct Details on the various trait implementations for the Visit struct, including Clone, Debug, From, Hash, PartialEq, and more. ```APIDOC ## Trait Implementations for Visit ### Clone * **`clone(&self) -> Visit`**: Returns a duplicate of the value. * **`clone_from(&mut self, source: &Self)`**: Performs copy-assignment from `source`. ### Debug * **`fmt(&self, f: &mut Formatter<'_>) -> Result`**: Formats the value using the given formatter. ### From * **`from(label: UntypedEdgeLabel) -> Visit`**: Converts to this type from the input type. ### From * **`from(v: Visit) -> EdgeLabel`**: Converts to this type from the input type. ### From * **`from(n: u64) -> Visit`**: Converts to this type from the input type. ### Hash * **`hash<__H: Hasher>(&self, state: &mut __H)`**: Feeds this value into the given `Hasher`. * **`hash_slice(data: &[Self], state: &mut H)`**: Feeds a slice of this type into the given `Hasher`. ### PartialEq * **`eq(&self, other: &Visit) -> bool`**: Tests for `self` and `other` values to be equal. * **`ne(&self, other: &Rhs) -> bool`**: Tests for `!=`. ### TryFrom * **`type Error = ()`**: The type returned in the event of a conversion error. * **`try_from(label: EdgeLabel) -> Result`**: Performs the conversion. ### Copy * No specific methods to document, indicates the struct is `Copy`. ### Eq * No specific methods to document, indicates the struct is `Eq`. ### StructuralPartialEq * No specific methods to document, indicates the struct has structural equality. ### Auto Trait Implementations * **Freeze, RefUnwindSafe, Send, Sync, Unpin, UnwindSafe**: These indicate thread-safety and memory management characteristics. ``` -------------------------------- ### Permutation Trait - get() Method (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/map/trait The `get` method safely retrieves an item from the permutation using its index. It returns an Option to handle cases where the index might be out of bounds. ```Rust fn get(&self, old_node: usize) -> Option; ``` -------------------------------- ### Get Pointer Alignment Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct The alignment of the pointer. This is a constant associated with the `Pointable` trait. ```rust const ALIGN: usize ``` -------------------------------- ### Initialize SwhUnidirectionalGraph Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Creates a new instance of SwhUnidirectionalGraph with a specified base path. ```Rust pub fn new(basepath: impl AsRef) -> Result ``` -------------------------------- ### SwhUnidirectionalGraph Initialization Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Provides methods for creating and initializing a SwhUnidirectionalGraph instance. ```APIDOC ## POST /websites/rs_swh-graph_swh_graph ### Description Initializes a new unidirectional graph from a base path. ### Method POST ### Endpoint /websites/rs_swh-graph_swh_graph ### Parameters #### Path Parameters - **basepath** (impl AsRef) - Required - The base path to the graph data. ### Request Example ```json { "basepath": "./graph" } ``` ### Response #### Success Response (200) - **SwhUnidirectionalGraph** (object) - The initialized graph object. #### Response Example ```json { "graph": "initialized_graph_object" } ``` ``` ```APIDOC ## POST /websites/rs_swh-graph_swh_graph/from_underlying_graph ### Description Creates a SwhUnidirectionalGraph from an existing underlying graph. ### Method POST ### Endpoint /websites/rs_swh-graph_swh_graph/from_underlying_graph ### Parameters #### Path Parameters - **basepath** (PathBuf) - Required - The base path for the graph. - **graph** (G: UnderlyingGraph) - Required - The underlying graph to use. ### Request Example ```json { "basepath": "./graph", "graph": "existing_underlying_graph" } ``` ### Response #### Success Response (200) - **SwhUnidirectionalGraph** (object) - The graph created from the underlying graph. #### Response Example ```json { "graph": "graph_from_underlying" } ``` ``` ```APIDOC ## POST /websites/rs_swh-graph_swh_graph/init_properties ### Description Initializes properties for the graph, making it ready for loading properties. ### Method POST ### Endpoint /websites/rs_swh-graph_swh_graph/init_properties ### Parameters #### Request Body - **self** (SwhUnidirectionalGraph) - Required - The graph instance. ### Request Example ```json { "self": "graph_instance" } ``` ### Response #### Success Response (200) - **SwhUnidirectionalGraph** (object) - The graph with initialized properties. #### Response Example ```json { "graph": "graph_with_init_properties" } ``` ``` -------------------------------- ### Dereference Pointer Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Dereferences the given pointer to get an immutable reference. This is an unsafe function. ```rust unsafe fn deref<'a>(ptr: usize) -> &'a T ``` -------------------------------- ### Get Number of Arcs Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhGraph` trait to return the total number of arcs in the graph. ```Rust fn num_arcs(&self) -> u64 ``` -------------------------------- ### Rust: Initialize FrontCodedListBuilder Source: https://docs.rs/swh-graph/latest/swh_graph/front_coded_list/struct Creates a new instance of FrontCodedListBuilder. Requires a NonZeroUsize to specify the block size for the front-coded list. ```rust pub fn new(block_size: NonZeroUsize) -> Self ``` -------------------------------- ### PartitionedBuffer Methods Source: https://docs.rs/swh-graph/latest/swh_graph/utils/sort/struct Provides documentation for the methods available on the PartitionedBuffer struct, including methods for inserting data with and without labels. ```APIDOC ## Implementations Source ### impl + Copy, D: BitDeserializer + Copy> PartitionedBuffer Source #### pub fn insert_labeled( &mut self, partition_id: usize, src: usize, dst: usize, label: L, ) -> Result<()> Inserts a labeled edge into the buffer within a specified partition. * **Parameters** * `partition_id` (usize): The ID of the partition to insert into. * `src` (usize): The source node ID. * `dst` (usize): The destination node ID. * `label` (L): The label to associate with the edge. * **Returns** * `Result<()>`: Ok if insertion is successful, otherwise an error. Source ``` ```APIDOC ### impl PartitionedBuffer<(), (), ()> Source #### pub fn insert( &mut self, partition_id: usize, src: usize, dst: usize, ) -> Result<()> Inserts an unlabeled edge into the buffer within a specified partition. * **Parameters** * `partition_id` (usize): The ID of the partition to insert into. * `src` (usize): The source node ID. * `dst` (usize): The destination node ID. * **Returns** * `Result<()>`: Ok if insertion is successful, otherwise an error. Source ``` -------------------------------- ### Get Number of Nodes Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhGraph` trait to return the total number of nodes in the graph. ```Rust fn num_nodes(&self) -> usize ``` -------------------------------- ### Get Graph Path Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhGraph` trait to return the base file path of the graph. ```Rust fn path(&self) -> &Path ``` -------------------------------- ### FrontCodedListBuilder API Source: https://docs.rs/swh-graph/latest/swh_graph/front_coded_list/struct API documentation for the FrontCodedListBuilder struct, detailing its constructor and methods. ```APIDOC ## Struct FrontCodedListBuilder Represents a builder for a Front-Coded List. ### `new(block_size: NonZeroUsize) -> Self` Creates a new `FrontCodedListBuilder` with blocks of the given size. ### `push(&mut self, s: Vec) -> Result<(), PushError>` Adds a string at the end of the Front-Coded List. Returns `Err` if the string is not strictly greater than the previous one. ### `dump(&self, base_path: impl AsRef) -> Result<()>` Writes the FCL to disk at the specified base path. ``` -------------------------------- ### Get Successors in SwhUnidirectionalGraph Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhForwardGraph` trait to provide an iterator over the successors of a given node. ```Rust fn successors(&self, node_id: NodeId) -> Self::Successors<'_> ``` -------------------------------- ### Get Type ID Source: https://docs.rs/swh-graph/latest/swh_graph/map/struct Returns the unique TypeId for the OwnedPermutation instance. This is part of the Any trait implementation. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Create New Visit Instance Source: https://docs.rs/swh-graph/latest/swh_graph/labels/struct Provides a constructor function `new` for the Visit struct. It takes a VisitStatus and a u64 timestamp, returning an Option. It returns None if the timestamp is 2^59 or greater, indicating a potential overflow or invalid state. ```rust pub fn new(status: VisitStatus, timestamp: u64) -> Option ``` -------------------------------- ### Clone to Uninit Memory Source: https://docs.rs/swh-graph/latest/swh_graph/struct Implements `CloneToUninit` for `T` where `T` is `Clone`. This is a nightly-only experimental API for cloning into uninitialized memory, potentially for performance optimizations. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Mutably Dereference Pointer Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Mutably dereferences the given pointer to get a mutable reference. This is an unsafe function. ```rust unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ``` -------------------------------- ### Initialize Graph Properties Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Prepares the graph for loading properties by initializing its property structure. This is a prerequisite for methods like `load_properties`. ```Rust pub fn init_properties( self, ) -> SwhUnidirectionalGraph, G> ``` -------------------------------- ### Get Type Witness Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct A constant of the type witness. It provides a mechanism to express type equality constraints. ```rust const WITNESS: W = W::MAKE where W: MakeTypeWitness, T: ?Sized ``` -------------------------------- ### Get Outdegree in SwhUnidirectionalGraph Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhForwardGraph` trait to return the number of successors (outdegree) for a given node. ```Rust fn outdegree(&self, node_id: NodeId) -> usize ``` -------------------------------- ### Load Graph Data Source: https://docs.rs/swh-graph/latest/swh_graph/_tutorial/index Loads a graph from a specified file path using the swh_graph crate. This function is generic over the MPH (Minimal Perfect Hashing) implementation. ```rust use std::path::PathBuf; let graph = swh_graph::graph::load_full::(PathBuf::from("./graph")) .expect("Could not load graph"); ``` -------------------------------- ### Get Underlying Graph of ContiguousSubgraph (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/views/struct Returns a reference to the underlying graph from which this `ContiguousSubgraph` was created. ```rust pub fn underlying_graph(&self) -> &G ``` -------------------------------- ### SWHID Constants and Methods in Rust Source: https://docs.rs/swh-graph/latest/swh_graph/struct Provides the size of the binary representation of a SWHID and a method to create a SWHID from an origin URI. ```rust pub const BYTES_SIZE: usize = 22usize; pub fn from_origin_url(origin: impl AsRef) -> SWHID ``` -------------------------------- ### Get Actual Number of Nodes Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhGraph` trait to return the actual number of nodes in the graph, if known. ```Rust fn actual_num_nodes(&self) -> Result ``` -------------------------------- ### Get Node Counts by Type Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhGraph` trait to retrieve a map of node types to their counts, if known. ```Rust fn num_nodes_by_type(&self) -> Result> ``` -------------------------------- ### Get TypeId of Self (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/arc_iterators/struct Retrieves the unique `TypeId` for the current type. This is part of the `Any` trait implementation. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Building Executable for Linux Distribution Source: https://docs.rs/swh-graph/latest/swh_graph/index Builds a release executable for Linux using musl, targeting a specific CPU architecture for optimization. Ensures compatibility with a defined set of CPU features. ```bash RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --release --target x86_64-unknown-linux-musl ``` -------------------------------- ### Get Type ID Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Retrieves the unique TypeId for a given type. This is a common function available through blanket implementations for any type. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Get Arc Counts by Type Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Implements the `SwhGraph` trait to retrieve a map of arc type pairs to their counts, if known. ```Rust fn num_arcs_by_type(&self) -> Result> ``` -------------------------------- ### Get Pointer Alignment Source: https://docs.rs/swh-graph/latest/swh_graph/compress/zst_dir/struct Defines the alignment requirement for a type used with pointer-based operations. This constant indicates the memory alignment in bytes. ```rust const ALIGN: usize ``` -------------------------------- ### Initialize LabelNameHasher Source: https://docs.rs/swh-graph/latest/swh_graph/compress/label_names/struct Provides a constructor function `new` for creating a `LabelNameHasher` instance. It requires references to `LabelNameMphf` and `MappedPermutation`, returning a `Result`. ```rust pub fn new( mphf: &'a LabelNameMphf, order: &'a MappedPermutation, ) -> Result ``` -------------------------------- ### Rust: Type Conversion with From and Into Source: https://docs.rs/swh-graph/latest/swh_graph/utils/mmap/struct Demonstrates type conversions using the `From` and `Into` traits. `From` allows creating a type from another type `T`, while `Into` provides a convenient way to call `U::from(self)` for conversion. ```rust impl From for T fn from(t: T) -> T Returns the argument unchanged. ``` ```rust impl Into for T where U: From, fn into(self) -> U Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ``` -------------------------------- ### Get Bit Field Length Source: https://docs.rs/swh-graph/latest/swh_graph/map/struct Returns the number of elements (not bits) in the bit field slice. Part of the BitFieldSliceCore trait. ```rust fn len(&self) -> usize ``` -------------------------------- ### PartitionedBuffer Blanket Implementations Source: https://docs.rs/swh-graph/latest/swh_graph/utils/sort/struct Documents the blanket implementations provided for the PartitionedBuffer struct, covering standard traits like Any, Borrow, and From. ```APIDOC ## Blanket Implementations Source ### impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Source ### impl Borrow for T where T: ?Sized, #### fn borrow(&self) -> &T Immutably borrows from an owned value. Source ### impl BorrowMut for T where T: ?Sized, #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. Source ### impl CastableFrom for T #### fn cast_from(value: T) -> T Call `Self as W` Source ### impl CastableFrom for T #### fn cast_from(value: T) -> T Call `Self as W` Source ### impl CastableInto for T where U: CastableFrom, #### fn cast(self) -> U Call `W::cast_from(self)` Source ### impl CastableInto for T where U: CastableFrom, #### fn cast(self) -> U Call `W::cast_from(self)` Source ### impl Conv for T #### fn conv(self) -> T where Self: Into, Converts `self` into `T` using `Into`. Source ### impl DowncastableFrom for T #### fn downcast_from(value: T) -> T Truncate the current UnsignedInt to a possibly smaller size Source ### impl DowncastableFrom for T #### fn downcast_from(value: T) -> T Truncate the current UnsignedInt to a possibly smaller size Source ### impl DowncastableInto for T where U: DowncastableFrom, #### fn downcast(self) -> U Call `W::downcast_from(self)` Source ### impl DowncastableInto for T where U: DowncastableFrom, #### fn downcast(self) -> U Call `W::downcast_from(self)` Source ### impl FmtForward for T #### fn fmt_binary(self) -> FmtBinary where Self: Binary, Formats `self` using its `Binary` implementation when `Debug`-formatted. Source #### fn fmt_display(self) -> FmtDisplay where Self: Display, Formats `self` using its `Display` implementation when `Debug`-formatted. Source #### fn fmt_lower_exp(self) -> FmtLowerExp where Self: LowerExp, Formats `self` using its `LowerExp` implementation when `Debug`-formatted. Source #### fn fmt_lower_hex(self) -> FmtLowerHex where Self: LowerHex, Formats `self` using its `LowerHex` implementation when `Debug`-formatted. Source #### fn fmt_octal(self) -> FmtOctal where Self: Octal, Formats `self` using its `Octal` implementation when `Debug`-formatted. Source #### fn fmt_pointer(self) -> FmtPointer where Self: Pointer, Formats `self` using its `Pointer` implementation when `Debug`-formatted. Source #### fn fmt_upper_exp(self) -> FmtUpperExp where Self: UpperExp, Formats `self` using its `UpperExp` implementation when `Debug`-formatted. Source #### fn fmt_upper_hex(self) -> FmtUpperHex where Self: UpperHex, Formats `self` using its `UpperHex` implementation when `Debug`-formatted. Source #### fn fmt_list(self) -> FmtList where &'a Self: for<'a> IntoIterator, Formats each item in a sequence. Source ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. Source ### impl HasTypeWitness for T where W: MakeTypeWitness, T: ?Sized, #### const WITNESS: W = W::MAKE A constant of the type witness Source ### impl Identity for T where T: ?Sized, #### const TYPE_EQ: TypeEq::Type> = TypeEq::NEW Proof that `Self` is the same type as `Self::Type`, provides methods for casting between `Self` and `Self::Type`. Source ``` -------------------------------- ### Get Length of Permutation Source: https://docs.rs/swh-graph/latest/swh_graph/map/struct Returns the total number of elements in the permutation. Implements the Permutation trait's len method. ```rust fn len(&self) -> usize ``` -------------------------------- ### Generate Graph Index Files with swh-graph-index Source: https://docs.rs/swh-graph/latest/swh_graph/index Demonstrates how to use the 'swh-graph-index' command to generate essential graph index files (.ef and .offsets). These files enable random access to graph data, with specific subcommands for 'offsets', 'ef', 'labels-ef', and 'dcf' (degree-cumulative function). ```shell swh-graph$ ./target/debug/swh-graph-index --help ``` -------------------------------- ### Generic Formatting Implementations in Rust Source: https://docs.rs/swh-graph/latest/swh_graph/graph_builder/struct Details blanket implementations for `FmtForward` methods, allowing custom formatting for types implementing various display traits. ```Rust impl FmtForward for T { fn fmt_binary(self) -> FmtBinary fn fmt_display(self) -> FmtDisplay fn fmt_lower_exp(self) -> FmtLowerExp fn fmt_lower_hex(self) -> FmtLowerHex fn fmt_octal(self) -> FmtOctal fn fmt_pointer(self) -> FmtPointer fn fmt_upper_exp(self) -> FmtUpperExp fn fmt_upper_hex(self) -> FmtUpperHex fn fmt_list(self) -> FmtList } ``` -------------------------------- ### Get Iterator Subsections by Index Source: https://docs.rs/swh-graph/latest/swh_graph/compress/zst_dir/struct Retrieves a subsection of an iterator based on an index type that implements `IteratorIndex`. Returns an iterator over the specified range. ```rust fn get(self, index: R) -> >::Output where Self: Sized, R: IteratorIndex, ``` -------------------------------- ### NodeBuilder Methods Source: https://docs.rs/swh-graph/latest/swh_graph/graph_builder/struct Methods available for the NodeBuilder to configure and build graph nodes. ```APIDOC ## NodeBuilder API ### Description Provides methods to construct and configure graph nodes using the `NodeBuilder`. ### Methods #### `done()` - **Description**: Finalizes the node construction and returns a `NodeId`. - **Method**: `GET` (or implicitly called after configuration) - **Endpoint**: Not applicable (method on a struct) - **Return Type**: `NodeId` #### `content_length(content_length: u64)` - **Description**: Sets the content length for the node. - **Method**: `POST` (or similar builder pattern method) - **Endpoint**: Not applicable - **Parameters**: - `content_length` (u64) - Required - The length of the content. - **Return Type**: `&mut Self` (for chaining) #### `is_skipped_content(is_skipped_content: bool)` - **Description**: Sets a flag indicating if the content is skipped. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `is_skipped_content` (bool) - Required - True if content is skipped, false otherwise. - **Return Type**: `&mut Self` #### `author(author: Vec)` - **Description**: Sets the author information for the node. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `author` (Vec) - Required - The author's identifier (e.g., hash). - **Return Type**: `&mut Self` #### `committer(committer: Vec)` - **Description**: Sets the committer information for the node. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `committer` (Vec) - Required - The committer's identifier. - **Return Type**: `&mut Self` #### `message(message: Vec)` - **Description**: Sets the commit message for the node. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `message` (Vec) - Required - The commit message content. - **Return Type**: `&mut Self` #### `tag_name(tag_name: Vec)` - **Description**: Sets the tag name associated with the node. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `tag_name` (Vec) - Required - The name of the tag. - **Return Type**: `&mut Self` #### `author_timestamp(ts: i64, offset: i16)` - **Description**: Sets the author's timestamp and timezone offset. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `ts` (i64) - Required - The Unix timestamp. - `offset` (i16) - Required - The timezone offset in minutes. - **Return Type**: `&mut Self` #### `committer_timestamp(ts: i64, offset: i16)` - **Description**: Sets the committer's timestamp and timezone offset. - **Method**: `POST` - **Endpoint**: Not applicable - **Parameters**: - `ts` (i64) - Required - The Unix timestamp. - `offset` (i16) - Required - The timezone offset in minutes. - **Return Type**: `&mut Self` ``` -------------------------------- ### Get TypeId of a Rust Value Source: https://docs.rs/swh-graph/latest/swh_graph/views/struct Retrieves the `TypeId` of a given value. This is a common operation for runtime type introspection in Rust. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Get Successors in ContiguousSubgraph (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/views/struct Returns an iterator over the successors of a given node ID in the `ContiguousSubgraph`. Implements the `SwhForwardGraph` trait. ```rust type Successors<'succ> = TranslatedSuccessors<'succ, <::Successors<'succ> as IntoIterator>::IntoIter, N> where Self: 'succ fn successors(&self, node_id: NodeId) -> Self::Successors<'_> ``` -------------------------------- ### Generic CloneToUninit Method Implementation Source: https://docs.rs/swh-graph/latest/swh_graph/compress/persons/struct Implements the `unsafe fn clone_to_uninit` for generic types `T` that implement `Clone`. This is a nightly-only experimental API for copying to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. Read more ``` -------------------------------- ### Get Predecessors in ContiguousSubgraph (Rust) Source: https://docs.rs/swh-graph/latest/swh_graph/views/struct Returns an iterator over the predecessors of a given node ID in the `ContiguousSubgraph`. Implements the `SwhBackwardGraph` trait. ```rust type Predecessors<'succ> = TranslatedSuccessors<'succ, <::Predecessors<'succ> as IntoIterator>::IntoIter, N> where Self: 'succ fn predecessors(&self, node_id: NodeId) -> Self::Predecessors<'_> ``` -------------------------------- ### Initialize SwhBidirectionalGraph Source: https://docs.rs/swh-graph/latest/swh_graph/graph/index Initializes a new bidirectional Software Heritage graph. Use this to create a graph structure that allows traversal in both directions. ```Rust pub fn new() -> Self; ``` -------------------------------- ### Get Length of NumberMmap in Rust Source: https://docs.rs/swh-graph/latest/swh_graph/utils/mmap/struct Returns the total number of items that can be accessed in the `NumberMmap`. This method is available on the `NumberMmap` struct itself. ```rust pub fn len(&self) -> usize ``` -------------------------------- ### Compile swh-graph Binary Assets Source: https://docs.rs/swh-graph/latest/swh_graph/index Compiles all features of the swh-graph project using Cargo. This process builds binary assets in the local 'target/debug' directory, including the 'swh-graph-index' executable. ```shell swh-graph$ cargo build --all-features ``` -------------------------------- ### Depth-First Traversal Implementation Source: https://docs.rs/swh-graph/latest/swh_graph/_tutorial/index Implements a generic Depth-First Search (DFS) traversal for graphs that implement the `SwhForwardGraph` trait. It uses a stack and a set to keep track of visited nodes. ```rust use std::collections::HashSet; use std::path::PathBuf; use swh_graph::graph::*; fn visit_nodes_dfs(graph: G, root: NodeId) { let mut stack = Vec::new(); let mut visited = HashSet::new(); stack.push(root); visited.insert(root); while let Some(node) = stack.pop() { println!("{}", node); for succ in graph.successors(node) { if !visited.contains(&succ) { stack.push(succ); visited.insert(succ); } } } } ``` -------------------------------- ### Get Bit Field Width Source: https://docs.rs/swh-graph/latest/swh_graph/map/struct Returns the total bit width of the underlying data for the bit field. Part of the BitFieldSliceCore trait. ```rust fn bit_width(&self) -> usize ``` -------------------------------- ### Dump GOV3 to C-compatible format using jshell Source: https://docs.rs/swh-graph/latest/swh_graph/java_compat/sf/gov3/struct Demonstrates how to dump a serialized Java instance of the GOV3 static function into a C-compatible format using jshell. This creates a file that can be read by the Rust GOV3 structure's `load` method. ```java echo '((it.unimi.dsi.sux4j.mph.GOV3Function)it.unimi.dsi.fastutil.io.BinIO.loadObject("test.sf")).dump("test.csf");' | jshell ``` -------------------------------- ### Get Untyped Labeled Successors Source: https://docs.rs/swh-graph/latest/swh_graph/graph/struct Returns an iterator over the successors of a given node, along with labels for each arc. This function is part of the SwhLabeledForwardGraph trait. ```rust fn untyped_labeled_successors( &self, node_id: NodeId, ) -> Self::LabeledSuccessors<'_> ``` -------------------------------- ### Get Labeled Predecessors in Rust Source: https://docs.rs/swh-graph/latest/swh_graph/views/struct Returns an iterator over the predecessors of a node, along with the labels of the arcs connecting them. This method is for labeled graphs. ```Rust fn untyped_labeled_predecessors( &self, node_id: NodeId, ) -> Self::LabeledPredecessors<'_> ``` ```Rust fn labeled_predecessors( &self, node_id: NodeId, ) -> impl Iterator)> where Self: SwhGraphWithProperties + Sized, ::Maps: Maps, ```