Home / File/ machine.rs — tailwindcss Source File

machine.rs — tailwindcss Source File

Architecture documentation for machine.rs, a rust file in the tailwindcss codebase. 3 imports, 0 dependents.

File rust OxideEngine Extractor 3 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  4c43dba8_bb08_844b_c3a0_aaf9e55dffb8["machine.rs"]
  e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e["crate::cursor"]
  4c43dba8_bb08_844b_c3a0_aaf9e55dffb8 --> e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e
  47b0f6b9_25fb_1ddf_6cf7_af1d1733d85c["crate::throughput::Throughput"]
  4c43dba8_bb08_844b_c3a0_aaf9e55dffb8 --> 47b0f6b9_25fb_1ddf_6cf7_af1d1733d85c
  cc79870b_65f6_c4e5_bd7d_4f3d41ad1300["std::hint::black_box"]
  4c43dba8_bb08_844b_c3a0_aaf9e55dffb8 --> cc79870b_65f6_c4e5_bd7d_4f3d41ad1300
  style 4c43dba8_bb08_844b_c3a0_aaf9e55dffb8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use crate::cursor;

#[derive(Debug, Clone, Copy)]
pub struct Span {
    /// Inclusive start position of the span
    pub start: usize,

    /// Inclusive end position of the span
    pub end: usize,
}

impl Span {
    pub fn new(start: usize, end: usize) -> Self {
        Self { start, end }
    }

    #[inline(always)]
    pub fn slice<'a>(&self, input: &'a [u8]) -> &'a [u8] {
        &input[self.start..=self.end]
    }
}

#[derive(Debug, Default)]
pub enum MachineState {
    /// Machine is not doing anything at the moment
    #[default]
    Idle,

    /// Machine is done parsing and has extracted a span
    Done(Span),
}

pub trait Machine: Sized + Default {
    fn reset(&mut self);
    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState;

    /// Reset the state machine, and mark the machine as [MachineState::Idle].
    #[inline(always)]
    fn restart(&mut self) -> MachineState {
        self.reset();
        MachineState::Idle
    }

    /// Reset the state machine, and mark the machine as [MachineState::Done(…)].
    #[inline(always)]
    fn done(&mut self, start: usize, cursor: &cursor::Cursor<'_>) -> MachineState {
        self.reset();
        MachineState::Done(Span::new(start, cursor.pos))
    }

    #[cfg(test)]
    fn test_throughput(iterations: usize, input: &str) {
        use crate::throughput::Throughput;
        use std::hint::black_box;

        let input = input.as_bytes();
        let len = input.len();

        let throughput = Throughput::compute(iterations, len, || {
            let mut machine = Self::default();
// ... (102 more lines)

Domain

Subdomains

Functions

Classes

Dependencies

  • crate::cursor
  • crate::throughput::Throughput
  • std::hint::black_box

Frequently Asked Questions

What does machine.rs do?
machine.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the OxideEngine domain, Extractor subdomain.
What functions are defined in machine.rs?
machine.rs defines 2 function(s): new, slice.
What does machine.rs depend on?
machine.rs imports 3 module(s): crate::cursor, crate::throughput::Throughput, std::hint::black_box.
Where is machine.rs in the architecture?
machine.rs is located at crates/oxide/src/extractor/machine.rs (domain: OxideEngine, subdomain: Extractor, directory: crates/oxide/src/extractor).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free