Reformat, docs

This commit is contained in:
Jan-Erik Rediger
2023-03-12 19:42:50 +01:00
parent 37aa6b2017
commit e20f8f6d9d
3 changed files with 15 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
use std::{env, io::Write};
use tsnet::{ServerBuilder, Network};
use tsnet::{Network, ServerBuilder};
fn main() {
let target = env::args()
+6 -2
View File
@@ -4,11 +4,15 @@ use std::{
thread,
};
use tsnet::{ServerBuilder, Network};
use tsnet::{Network, ServerBuilder};
fn main() {
env_logger::init();
let ts = ServerBuilder::new().ephemeral().redirect_log().build().unwrap();
let ts = ServerBuilder::new()
.ephemeral()
.redirect_log()
.build()
.unwrap();
let ln = ts.listen(Network::Tcp, ":1999").unwrap();
for conn in ln {
+8 -5
View File
@@ -49,7 +49,9 @@
//! write!(conn, "This is a test of the Tailscale connection service.\n").unwrap();
//! }
//! ```
#[deny(missing_docs)]
#![deny(missing_docs)]
#![allow(clippy::needless_doctest_main)]
#[allow(non_camel_case_types, dead_code)]
mod sys;
@@ -95,6 +97,7 @@ pub enum Error {
NullInString(#[from] std::ffi::NulError),
}
/// A Result, returning either a value or an error, defaulting to the crate error.
pub type Result<T, E = Error> = std::result::Result<T, E>;
/// The possible network types.
@@ -424,6 +427,10 @@ pub struct Listener {
}
impl Listener {
/// Accept a new incoming connection from this listener.
///
/// This function will block the calling thread until a new connection is established.
/// When established, the corresponding `TcpStream` will be returned.
pub fn accept(&self) -> Result<TcpStream, Error> {
unsafe {
let mut conn = 0;
@@ -435,10 +442,6 @@ impl Listener {
res.map(|_| TcpStream::from_raw_fd(conn))
}
}
pub fn incoming(&mut self) -> &Self {
self
}
}
impl Drop for Listener {