Coder Social home page Coder Social logo

lazuli's Introduction

lazuli: A rust socket library for consistent, quick, and easy data transfer

lazuli is a socket library that provides a simple interface for sending and receiving data over a network. It is designed to be easy to use, fast, and reliable. lazuli is built on top of the standard Rust std::net library, and provides a more user-friendly API for working with sockets.

Features

  • Simple API for sending and receiving data
  • Support for TCP sockets
  • Non-blocking I/O
  • Cross-platform support
  • Standard error types for easy error handling

Usage

Lazuli uses a simple API that consists of a Client, Server, and Stream<T> struct. The Client struct is used to connect to a server and send data, the Server struct is used to listen for incoming connections, and the Stream<T> struct is used to receive data.

Here is an example of how to use lazuli to send and receive data:

let client = Client::connect(("127.0.0.1", 8080))

let stream = client.stream::<String>();

client.send("Hello, world!".to_string());

let data = stream.recv().unwrap();

println!("Received data: {}", data);

Contributing

Contributions are welcome! If you would like to contribute to lazuli, please open an issue or submit a pull request. If you are submitting a pull request, please make sure to run a cargo fmt before submitting.

License

lazuli is licensed under the GNU GPL v3.0. See the LICENSE file for more information.

lazuli's People

Contributors

quackitsquinn avatar

Watchers

 avatar

lazuli's Issues

Add a Socket Config Struct

Add a socket config struct that would be given to Client and Server that would configure the underlying socket. It would allow you to configure the standard unix socket options.

This should give both Server and Client a with_config(&mut self, config: SocketConfig) method.

Remove `Sendable` `Debug` bound

The trait Sendable currently is bound to types that implement Debug. This bound should be removed. Most types will implement Debug, but it shouldn't be assumed that all sent types will be.

Have tests use socket 0 for `TcpListeners`

When you use socket 0 for a TcpListener, the OS will automatically give it a unique port. This is better than the current solution of trying until we find an empty one.

Change Packet Header

Currently, PacketHeaders have a signature of RSOCK. rsock was the development name of lazuli.

If more space for the header is fine, it could be changed to LAZULI, but this might be too much. It might be a good idea to just change it to something like LAZI or ZULI or something that still is 4 characters long.

Remove `as_conversion_fn` from `Sendable`

as_conversion_fn is a function that should only be used internally, yet it is exposed because it is part of the Sendable trait.

This should be moved to a pub(crate) fn to prevent it being used outside the crate.

Improve Documentation

Currently, Documentation is not fully concise, and sometimes is spotty. This needs to be fixed. There needs to be more examples on most of the documentation, and more details about the usage of items in the documentation.

Lazuli should also start using #[warn(missing_docs)] to help keep documentation consistent.

Tests for `SocketListener`

SocketListener currently has zero tests. This needs to change.

The tests need to ensure that it can properly do the following:

  • Shutdown in a timely manner
  • Receive data consistently
    • This could probably be accomplished by waiting a few ms for it to send the data, but this should probably be swapped for a more elegant solution.

Rename the `client` Module

The client module does not just contain the client. It contains the Client, the Server, and the SocketListener. The name client is outdated and either needs to be changed or the location of Server and SocketListener needs to be changed.

Add more examples

There is currently only one example. This example does not cover any advanced usage of the library. There needs to be more examples.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.