Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungI built a sell planner to dodge the pros. They were under 4% of buys(25.09.2026 um 04:26 Uhr)
•
Sichere ProgrammierungNansen called Binance 14 a 'Token Billionaire'. The name cost 1 credit(25.09.2026 um 04:26 Uhr)
•
Sichere Programmierung50,000 property tests passed while my app crowned an impostor(25.09.2026 um 04:26 Uhr)
•
Sichere ProgrammierungI made a small website to check Codex reset(25.09.2026 um 04:28 Uhr)
•
Sichere ProgrammierungAI Is My Workforce, Not My Replacement(25.09.2026 um 04:30 Uhr)
•
AI & KI NachrichtenThe Machine Learning Career Roadmap I'd Follow If I Started Today(25.09.2026 um 04:30 Uhr)
•••
Sichere ProgrammierungNormalize Units at the Boundary, or Ship a 12x Bug(25.09.2026 um 04:39 Uhr)
•
Sichere ProgrammierungA No-Repeat Random Draw Looks Trivial Until Round 70(25.09.2026 um 04:40 Uhr)
•
Sichere ProgrammierungI built a sell planner to dodge the pros. They were under 4% of buys(25.09.2026 um 04:26 Uhr)
•
Sichere ProgrammierungNansen called Binance 14 a 'Token Billionaire'. The name cost 1 credit(25.09.2026 um 04:26 Uhr)
•
Sichere Programmierung50,000 property tests passed while my app crowned an impostor(25.09.2026 um 04:26 Uhr)
•
Sichere ProgrammierungI made a small website to check Codex reset(25.09.2026 um 04:28 Uhr)
•
Sichere ProgrammierungAI Is My Workforce, Not My Replacement(25.09.2026 um 04:30 Uhr)
•
AI & KI NachrichtenThe Machine Learning Career Roadmap I'd Follow If I Started Today(25.09.2026 um 04:30 Uhr)
•••
Sichere ProgrammierungNormalize Units at the Boundary, or Ship a 12x Bug(25.09.2026 um 04:39 Uhr)
•
Sichere ProgrammierungA No-Repeat Random Draw Looks Trivial Until Round 70(25.09.2026 um 04:40 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

🚀 Rust Basics 5: Structs and Enums in Rust

Welcome back. This is the 5th post of our 7 post Rust tutorial. Structs and enums are fundamental tools in Rust to organize and represent data. They make your code more readable, efficient, and expressive. Step 1: What Are Structs? A…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Welcome back. This is the 5th post of our 7 post Rust tutorial.



Structs and enums are fundamental tools in Rust to organize and represent data. They make your code more readable, efficient, and expressive.



Step 1: What Are Structs?

A struct is like a blueprint for creating custom data types that group related information together.



Example: A Person Struct

Here’s how you define and use a struct:





struct Person {
name: String,
age: u8, // u8 means an unsigned 8-bit integer (0–255)
}

fn main() {
// Create an instance of the Person struct
let person = Person {
name: String::from("Chisom"),
age: 25,
};

// Access and print struct fields
println!("Name: {}, Age: {}", person.name, person.age);
}










Explanation

Defining a Struct:



struct Person defines the structure.

It has two fields: name (a string) and age (a number).



Creating an Instance:

Person { name: String::from("Chisom"), age: 25 } creates a Person instance.



Accessing Fields:

Use person.name and person.age to access the data.





Step 2: Adding Methods to Structs

You can add methods (functions) to structs to perform operations on their data.



Example: A Rectangle Struct with an area Method




struct Rectangle {
width: u32, // u32 means an unsigned 32-bit integer
height: u32,
}

impl Rectangle {
// Define a method to calculate area
fn area(&self) -> u32 {
self.width * self.height
}
}

fn main() {
let rect = Rectangle { width: 10, height: 5 };
println!("The area of the rectangle is: {}", rect.area());
}






Explanation

impl Rectangle: Implements methods for the Rectangle struct.

fn area(&self): A method that calculates the area.

&self refers to the instance being used.

You call the method with rect.area().





Step 3: What Are Enums?

An enum represents a type that can have one of several predefined variants. Think of it as a way to describe "one thing out of many options."



Example: A Direction Enum




enum Direction {
Up,
Down,
Left,
Right,
}

fn main() {
let movement = Direction::Up;

match movement {
Direction::Up => println!("Going up!"),
Direction::Down => println!("Going down!"),
Direction::Left => println!("Going left!"),
Direction::Right => println!("Going right!"),
}
}







Explanation

Defining an Enum:



enum Direction defines possible directions: Up, Down, Left, Right.

Using match:



match checks which variant is used and runs the corresponding code.

Each arm of match corresponds to a variant of the enum.





Step 4: Enums with Data



Enums can also hold data for each variant.



Example: A Message Enum




enum Message {
Text(String),
Number(i32),
}

fn main() {
let msg = Message::Text(String::from("Hello"));

match msg {
Message::Text(text) => println!("Message: {}", text),
Message::Number(num) => println!("Number: {}", num),
}
}







Explanation:

Each variant of Message can hold different types of data (String or i32).

match extracts the data inside the variant using patterns.

Practice for Today





Struct Practice:



Create a Car struct with fields for brand, model, and year.

Write a program to print a car's details.



Example:




struct Car {
brand: String,
model: String,
year: u16,
}

fn main() {
let car = Car {
brand: String::from("Toyota"),
model: String::from("Corolla"),
year: 2020,
};
println!("{} {} ({})", car.brand, car.model, car.year);
}










Enum Practice:



Create an enum Weather with variants Sunny, Rainy, and Cloudy.

Use match to print an appropriate message for each variant.



Example:




enum Weather {
Sunny,
Rainy,
Cloudy,
}

fn main() {
let today = Weather::Sunny;

match today {
Weather::Sunny => println!("It's a bright and sunny day!"),
Weather::Rainy => println!("Don't forget your umbrella!"),
Weather::Cloudy => println!("Looks like it might rain."),
}
}










🎉 That’s it for RUST BASICS 5! You’ve learned Structs and Enums. In the next post, we’ll learn Functions and Error Handling in Rust.



Feel free to share your solutions or ask questions in the comments. Happy coding! 🦀



Check out the Rust Documentation for more details.



Let me know if anything feels unclear!

Let me know how these examples feel, and if you'd like more exercises or clarification!

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - 🚀 Rust Basics 5: Structs and Enums in Rust
id: 0ed355f9-3025-4032-b2b9-1a9ee4fd042e
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "🚀 Rust Basics 5: Structs and E" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Rust Basics 5 Structs and Enums in Rust")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Rust Basics 5 Structs and Enums in Rust*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Rust Basics 5 Structs and Enums in Rust"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich 🚀 Rust Basics 5: Structs and Enums in Ru.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 🚀 Rust Basics 5: Structs and Enums in Rust

Thematisch verwandte Begriffe: Rust, Basics, Structs, Enums · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-87722 | Uncontrolled Resource Consumption (CWE-400 / CWE-1333) in regex search q…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle