I can't figure out how to display documentation from crates.io

I'm trying to get my small project, which is entirely displayed here:

use std::net::TcpStream;
use std::io::{Read, Write};


/// Reads network traffic sent by the send_network_traffic function. First,
/// a byte is sent denoting the number of byte sequences that will be read.
/// Next, the incoming byte count of the first section is received, followed
/// by the bytes being received. This happens for each section, until all
/// byte sequences are received. 
pub fn read_network_traffic(mut stream: TcpStream) -> Vec<Vec<u8>> {
    let mut byte_sequences = Vec::<Vec<u8>>::new();

    let mut section_count: [u8; 1] = [0; 1];

    match stream.read_exact(&mut section_count) {
        Ok(()) => {}
        Err(e) => panic!("Error: {:#?}", e),
    }

    while section_count[0] > 0 {
        section_count[0] -= 1;

        let mut incoming_byte_count: [u8; 8] = [0; 8];

        match stream.read_exact(&mut incoming_byte_count) {
            Ok(()) => {}
            Err(e) => panic!("Error: {:#?}", e),
        }

        let incoming = u64::from_be_bytes(incoming_byte_count);

        let mut incoming = usize::try_from(incoming).unwrap();

        let mut vec = vec![0; incoming];

        while incoming > 0 {
            incoming -= stream.read(&mut vec).unwrap();
        }

        byte_sequences.push(vec);
    }
    byte_sequences
}

/// Sends network traffic to the read_network_traffic function.
pub fn send_network_traffic(
    mut socket: TcpStream,
    byte_sequences: Vec<Vec<u8>>,
) -> TcpStream {
    // The section count is the length of the vector
    let section_count = byte_sequences.len();

    //transmit section count
        socket
        .write(&[section_count as u8])
        .unwrap();

    // transmit byte_sequences byte count
    for n in 0..section_count {
        let byte_sequences_len: [u8; 8] = byte_sequences[n as usize].len().to_be_bytes();
        
        socket.write(&byte_sequences_len).unwrap();
        
             socket
            .write(byte_sequences[n as usize].as_slice())
            .unwrap();
    }

    // return the connected stream
    socket
}

cargo.toml

[package]
name = "vec_router"
version = "0.0.2"
edition = "2024"

license = "MIT OR Apache-2.0"
description = "Networking code for sending and receiving vectors of vec<u8> on 64 bit systems"
keywords = ["networking"]

[dependencies]

To have documentation comments from crates.io. : crates.io: Rust Package Registry

but there is no documentation. Why isn't it showing the documentation comments above my two functions? I can view it locally with:

cargo doc --open

but there is no documentation link on the crates.io page.

Thanks for any help.

that is super interesting, normally docs show up on docs.rs instead of crates.io, but trying to search for your crate on docs.rs says documentation not available on docs.rs. Weird, I'm sorta stumped here. Hopefully someone way smarter can help you

The build queue is rather long. As of writing vec_router 0.0.2 is on position 94 (and 0.0.1 on position 578, it got deprioritized due to the newer release).
Docs will eventually show up at https://docs.rs/vec_router

5 Likes

Note that even after the docs.rs page becomes available (@jer already described the existence of the docs.rs build queue), you still won’t have a link to it on the crates.io page, unless you set the documentation link[1] in the [package] section of your Cargo.toml file.

Here’s the relevant entry in the cargo book. Ah, they also mention the docs.rs queue there, too :grinning_cat:.

Edit: Oh wait, nevermind, they mention there, they auto-link to docs.rs anyway!


  1. i.e. a line like:
    documentation = "https://docs.rs/vec_router" ↩︎

Are you sure? My crates seem to have a doc link without that. I think it is only needed if you want to host docs elsewhere and not on docs.rs (e.g. as embassy does).

1 Like

Yeah, yeah; I tried to check this beforehand – hadn’t found the cargo book yet – and drew wrong conclusions from examples… looking at other crates without any visible documentation link. (I think the one I saw was also still stuck in the queue.) I was just about to correct it already, anyway.

1 Like

Thanks everyone. I just had to have more patience! My project is now showing up for me with documentation.

1 Like