• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Blightmud / Blightmud / 14316676040

07 Apr 2025 06:27PM UTC coverage: 74.417% (-0.9%) from 75.283%
14316676040

push

github

web-flow
Merge pull request #1202 from Blightmud/dependabot/cargo/rustls-0.23.25

build(deps): bump rustls from 0.23.23 to 0.23.25

7089 of 9526 relevant lines covered (74.42%)

431.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.04
/src/lua/socket.rs
1
use std::{
2
    io::Write,
3
    net::{Shutdown, TcpStream},
4
};
5

6
use mlua::{UserData, UserDataMethods};
7

8
use crate::{
9
    event::Event,
10
    lua::{backend::Backend, constants::BACKEND},
11
    net::open_tcp_stream,
12
};
13

14
pub struct SocketLib;
15

16
impl UserData for SocketLib {
17
    fn add_methods<'lua, T: UserDataMethods<'lua, Self>>(methods: &mut T) {
165✔
18
        methods.add_function(
165✔
19
            "connect",
20
            |ctx, (host, port): (String, u16)| -> mlua::Result<Option<Socket>> {
×
21
                let backend: Backend = ctx.named_registry_value(BACKEND)?;
×
22
                if let Ok(connection) = open_tcp_stream(&host, port) {
×
23
                    Ok(Some(Socket { connection }))
×
24
                } else {
25
                    backend
×
26
                        .writer
×
27
                        .send(Event::Error(format!("Unable to connect to {host}:{port}")))
×
28
                        .unwrap();
×
29
                    Ok(None)
×
30
                }
31
            },
×
32
        );
33
    }
165✔
34
}
35

36
pub struct Socket {
37
    connection: TcpStream,
38
}
39

40
impl UserData for Socket {
41
    fn add_methods<'lua, T: UserDataMethods<'lua, Self>>(methods: &mut T) {
×
42
        methods.add_method_mut("send", |_, this, data: String| {
×
43
            let _ = this.connection.write(data.as_bytes());
×
44
            Ok(())
×
45
        });
×
46
        methods.add_method_mut("close", |_, this, ()| {
×
47
            let _ = this.connection.shutdown(Shutdown::Both);
×
48
            Ok(())
×
49
        });
×
50
    }
×
51
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc