Skip to main content

Crate tcplane

Crate tcplane 

Source
Expand description

tcplane

tcplane is a lightweight and high-performance Rust TCP server library designed to simplify network service development. It supports TCP communication, data stream management, and connection handling, focusing on providing efficient low-level network connections and data transmission capabilities, making it ideal for building modern network services.

Re-exports§

pub use crate::ServerHookHandler as MiddlewareHandler;
pub use crate::ServerHookList as MiddlewareList;
pub use tokio;

Structs§

ArcRwLockStream
A thread-safe wrapper around TcpStream using Arc<RwLock<TcpStream>>.
Context
The main connection context, providing thread-safe access to connection data.
DefaultHook
A default no-op hook implementation.
Response
Represents an HTTP-like response structure.
Server
The primary server structure that provides a thread-safe interface to the server’s state.
ServerConfig
Represents the thread-safe, shareable server configuration.
ServerControlHook
Represents the hooks for managing the server’s lifecycle, specifically for waiting and shutting down.

Enums§

ResponseError
Represents errors related to response operations.
ServerError
Represents errors that can occur at the server level.

Constants§

COLON
Colon symbol used in address formatting.
COLON_SPACE
Colon with space for display formatting.
DEFAULT_BUFFER_SIZE
Default buffer size for network operations (4KB).
DEFAULT_HOST
Default host address for the server.
DEFAULT_PORT
Default listening port for the server.
DEFAULT_SOCKET_ADDR
Default socket address.
SPLIT_REQUEST_BYTES
Request separator bytes for detecting end of request.

Traits§

AsyncFuncWithoutPin
Trait for async function handlers.
ServerHook
Trait for server lifecycle hooks that process connections.

Functions§

get_thread_count
Gets the number of available threads for parallel processing.
handler_fn
Creates a handler function from an async function.
remove_trailing_zeros
Removes trailing zero bytes from a byte vector.
server_hook_factory
Implementation of server hook handler factory functions. Creates a server hook handler factory from a type implementing ServerHook.

Type Aliases§

ArcErrorHandle
A type alias for arc-wrapped error handling function.
ArcRwLock
A type alias for Arc<RwLock<T>>.
ArcRwLockReadGuard
A type alias for read guard of ArcRwLock<T>.
ArcRwLockStreamReadGuard
A type alias for a read guard of ArcRwLock<TcpStream>.
ArcRwLockStreamWriteGuard
A type alias for a write guard of ArcRwLock<TcpStream>.
ArcRwLockWriteGuard
A type alias for write guard of ArcRwLock<T>.
ErrorHandleFn
A type alias for error handling function.
HandlerFunc
A type alias for a handler function.
HandlerList
A type alias for a list of handler functions.
HandlerListArc
A type alias for an arc-wrapped list of handlers.
HandlerListArcLock
A type alias for a RwLock-wrapped arc of handler list.
HashMapArcAnySendSync
A type alias for a hash map with Arc<dyn Any + Send + Sync> values.
OptionArcRwLockStream
A type alias for an optional ArcRwLockStream.
OptionSocketAddr
A type alias for an optional socket address.
OptionSocketHost
A type alias for an optional socket host (IP address).
OptionSocketPort
A type alias for an optional socket port.
Request
A type alias for request data (byte vector).
ResponseData
A type alias for response data (byte vector).
ResponseResult
A type alias for response result.
ServerHookHandler
A type alias for server hook handler function.
ServerHookList
A type alias for a list of server hook handlers.