Home / File/ rust.rs — tailwindcss Source File

rust.rs — tailwindcss Source File

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

File rust Oxide PreProcessors 8 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  e4f33efa_e6ad_42c6_e565_e6aa98401427["rust.rs"]
  9fa55369_02f4_df03_eceb_192db28541ed["super::Rust"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> 9fa55369_02f4_df03_eceb_192db28541ed
  9bfe5545_ae1a_8808_5f91_cbe10f598d06["crate::extractor::bracket_stack"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> 9bfe5545_ae1a_8808_5f91_cbe10f598d06
  8465ccb1_6be4_d6b2_3c4f_5f02d00df77d["crate::extractor::cursor"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> 8465ccb1_6be4_d6b2_3c4f_5f02d00df77d
  4d153f79_f78b_b66c_1e8a_11a0eb99bd41["crate::extractor::machine::Machine"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> 4d153f79_f78b_b66c_1e8a_11a0eb99bd41
  ed5b6564_5e78_f7bf_cdc6_b0150d9116c1["crate::extractor::pre_processors::pre_processor::PreProcessor"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> ed5b6564_5e78_f7bf_cdc6_b0150d9116c1
  087ad9fa_43e6_1338_b489_014631bd4014["crate::extractor::variant_machine::VariantMachine"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> 087ad9fa_43e6_1338_b489_014631bd4014
  b14a2969_5201_33cd_5f92_ba36c5024985["crate::extractor::MachineState"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> b14a2969_5201_33cd_5f92_ba36c5024985
  092d26da_8f74_08d1_48f1_765b79ca447c["bstr::ByteSlice"]
  e4f33efa_e6ad_42c6_e565_e6aa98401427 --> 092d26da_8f74_08d1_48f1_765b79ca447c
  style e4f33efa_e6ad_42c6_e565_e6aa98401427 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use crate::extractor::bracket_stack;
use crate::extractor::cursor;
use crate::extractor::machine::Machine;
use crate::extractor::pre_processors::pre_processor::PreProcessor;
use crate::extractor::variant_machine::VariantMachine;
use crate::extractor::MachineState;
use bstr::ByteSlice;

#[derive(Debug, Default)]
pub struct Rust;

impl PreProcessor for Rust {
    fn process(&self, content: &[u8]) -> Vec<u8> {
        // Leptos support: https://github.com/tailwindlabs/tailwindcss/pull/18093
        let replaced_content = content
            .replace(" class:", " class ")
            .replace("\tclass:", " class ")
            .replace("\nclass:", " class ");

        if replaced_content.contains_str(b"html!") {
            self.process_maud_templates(&replaced_content)
        } else {
            replaced_content
        }
    }
}

impl Rust {
    fn process_maud_templates(&self, replaced_content: &[u8]) -> Vec<u8> {
        let len = replaced_content.len();
        let mut result = replaced_content.to_vec();
        let mut cursor = cursor::Cursor::new(replaced_content);
        let mut bracket_stack = bracket_stack::BracketStack::default();

        while cursor.pos < len {
            match cursor.curr {
                // Escaped character, skip ahead to the next character
                b'\\' => {
                    cursor.advance_twice();
                    continue;
                }

                // Consume strings as-is
                b'"' => {
                    result[cursor.pos] = b' ';
                    cursor.advance();

                    while cursor.pos < len {
                        match cursor.curr {
                            // Escaped character, skip ahead to the next character
                            b'\\' => cursor.advance_twice(),

                            // End of the string
                            b'"' => {
                                result[cursor.pos] = b' ';
                                break;
                            }

                            // Everything else is valid
                            _ => cursor.advance(),
// ... (157 more lines)

Domain

Subdomains

Dependencies

  • bstr::ByteSlice
  • crate::extractor::MachineState
  • crate::extractor::bracket_stack
  • crate::extractor::cursor
  • crate::extractor::machine::Machine
  • crate::extractor::pre_processors::pre_processor::PreProcessor
  • crate::extractor::variant_machine::VariantMachine
  • super::Rust

Frequently Asked Questions

What does rust.rs do?
rust.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the Oxide domain, PreProcessors subdomain.
What functions are defined in rust.rs?
rust.rs defines 4 function(s): process, process_maud_templates, test_leptos_extraction, test_maud_template_extraction.
What does rust.rs depend on?
rust.rs imports 8 module(s): bstr::ByteSlice, crate::extractor::MachineState, crate::extractor::bracket_stack, crate::extractor::cursor, crate::extractor::machine::Machine, crate::extractor::pre_processors::pre_processor::PreProcessor, crate::extractor::variant_machine::VariantMachine, super::Rust.
Where is rust.rs in the architecture?
rust.rs is located at crates/oxide/src/extractor/pre_processors/rust.rs (domain: Oxide, subdomain: PreProcessors, directory: crates/oxide/src/extractor/pre_processors).

Analyze Your Own Codebase

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

Try Supermodel Free