# Label Documentation
Welcome to the `Label` section of our TUI library! This document provides an overview of the `Label` struct, which is essential for displaying text at specific positions in your terminal application.
## Overview
The `Label` struct allows you to create text labels that can be drawn on the console at designated coordinates. Whether you want to greet your users, display instructions, or simply add some flair to your TUI, the `Label` struct is your trusty companion!
### Struct Definition
```rust
pub struct Label {
text: String, // The text to be displayed by the label
x: u16, // The x-coordinate (horizontal position) where the label will be drawn
y: u16, // The y-coordinate (vertical position) where the label will be drawn
}
```
### Creating a Label
To create a new label, you can use the `new` method, which takes the text and coordinates as arguments.
```rust
pub fn new(text: &str, x: u16, y: u16) -> Self {
```
#### Arguments
- `text`: A string slice that holds the text of the label.
- `x`: The horizontal position (x-coordinate) where the label will be drawn.
- `y`: The vertical position (y-coordinate) where the label will be drawn.
#### Returns
- A new instance of `Label`.
### Drawing a Label
Once you have created a label, you can draw it on the console using the `draw` method.
```rust
pub fn draw(&self, stdout: &mut impl Write) -> io::Result<()> {
```
#### Arguments
- `stdout`: A mutable reference to any type that implements the `Write` trait, allowing the method to write the label's text to the specified output.
#### Errors
- Returns an `io::Result<()>`, which will contain an error if the write operation fails.
#### Example
```rust
use std::io::{self, Write};
let mut stdout = io::stdout();
let label = Label::new("Hello, world!", 10, 5);
label.draw(&mut stdout).unwrap(); // Draws the label
```