Skip to content

Commit dd8870c

Browse files
committed
2 parents 0f2ba0e + 9a2d669 commit dd8870c

38 files changed

+3567
-1612
lines changed

.github/workflows/gradle.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build and push to DockerHub
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Set up Docker Buildx
14+
uses: docker/setup-buildx-action@v3
15+
- name: Login to DockerHub
16+
uses: docker/login-action@v3
17+
with:
18+
registry: ghcr.io
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Build and push Docker image
22+
uses: docker/build-push-action@v5
23+
with:
24+
context: ./
25+
push: true
26+
tags: ghcr.io/mindustrytool/player-connect-server:latest

.github/workflows/rust-release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build and push to DockerHub
2+
on:
3+
push:
4+
branches:
5+
- v2
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Set up Docker Buildx
14+
uses: docker/setup-buildx-action@v3
15+
- name: Login to DockerHub
16+
uses: docker/login-action@v3
17+
with:
18+
registry: ghcr.io
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Build and push Docker image
22+
uses: docker/build-push-action@v5
23+
with:
24+
context: ./
25+
push: true
26+
tags: ghcr.io/mindustrytool/player-connect-server-rust:latest

.trae/rules/base.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
1. Project & File Structure Rules
2+
3+
One responsibility per module
4+
5+
Each mod should have a single clear purpose.
6+
7+
Avoid “god modules”.
8+
9+
Predictable layout
10+
11+
src/ main.rs error.rs config.rs
12+
13+
Public API at the top
14+
15+
pub struct, pub enum, pub fn first
16+
17+
Helpers and private impls later
18+
19+
2. Naming Rules (Very Important for AI)
20+
21+
Use descriptive names, never single letters ❌ x, tmp, r, v ✅ request, buffer, user_id, packet_type
22+
23+
Avoid abbreviations ❌ cfg, mgr, svc ✅ config, manager, service
24+
25+
Types > comments
26+
27+
Prefer expressive type names over comments
28+
29+
Boolean names must answer yes/no
30+
31+
is_connected has_permission should_retry
32+
33+
3. Type System Rules
34+
35+
Prefer strong types over primitives
36+
37+
struct UserId(u64); struct Port(u16);
38+
39+
Never use String when an enum fits
40+
41+
enum Protocol { Tcp, Udp, }
42+
43+
Avoid Option<T> for required data
44+
45+
Use constructor validation instead
46+
47+
Avoid Vec<u8> without context
48+
49+
struct PacketBytes(Vec<u8>);
50+
51+
4. Error Handling Rules
52+
53+
Never use unwrap() or expect() in library code
54+
55+
OK only in tests or binaries
56+
57+
Use a single error enum
58+
59+
enum AppError { Io(std::io::Error), InvalidPacket, Timeout, }
60+
61+
Errors must be meaningful ❌ Err(AppError::Invalid) ✅ Err(AppError::InvalidPacketHeader)
62+
63+
Implement Display for errors
64+
65+
AI tools rely on readable messages
66+
67+
5. Function Design Rules
68+
69+
Functions should fit on one screen
70+
71+
~20–40 lines max
72+
73+
One logical action per function
74+
75+
Avoid hidden side effects
76+
77+
No silent global mutation
78+
79+
Explicit input > implicit state
80+
81+
fn encode(packet: &Packet, buffer: &mut BytesMut)
82+
83+
Prefer returning values over mutating inputs
84+
85+
6. Ownership & Borrowing Rules
86+
87+
Prefer borrowing over cloning
88+
89+
fn process(data: &Data)
90+
91+
Clone only at API boundaries
92+
93+
Avoid complex lifetime annotations
94+
95+
If lifetimes get hard, redesign
96+
97+
Use Arc<T> only for shared ownership
98+
99+
Never “just in case”
100+
101+
7. Async & Concurrency Rules
102+
103+
Never block in async code ❌ std::thread::sleep ✅ tokio::time::sleep
104+
105+
Name async functions clearly
106+
107+
async fn fetch_user()
108+
109+
One async runtime
110+
111+
Do not mix Tokio + async-std
112+
113+
Use channels instead of shared mutable state
114+
115+
8. Run cargo check before committing, and fix all errors

0 commit comments

Comments
 (0)