Skip to main content
The fluxer_util crate contains helper utilities that are independent of the client or structs.

Permissions

Permissions is a bitflags struct for working with Fluxer access permissions. Based on the bitflags 2 crate.

Flags


parse_permissions

Parses a bitfield string from the API into Permissions. Returns an empty set on parse error.

permissions_to_string

Converts Permissions back into a bitfield string for passing to the API.

ALL_PERMISSIONS

A set containing all known flags. Equivalent to Permissions::all().

Flag Operations

Permissions supports standard bitflags operations:

SnowflakeUtil

Utilities for working with Snowflake IDs. Fluxer epoch: 1 420 070 400 000 ms (January 1, 2015, 00:00:00 UTC).

date_from_snowflake

Extracts the creation date of an object from its Snowflake ID. Returns None if the ID is not a number.

timestamp_ms_from_snowflake

Returns the Unix timestamp in milliseconds encoded in the Snowflake ID.

snowflake_from_timestamp

Generates the smallest possible Snowflake for a given Unix timestamp in milliseconds. Used for time-based pagination in API requests.

is_valid

Returns true if the string is a valid Snowflake (non-empty string, parseable as u64).

CDN

URL-building functions for Fluxer media resources. Exported from fluxer_core::util::cdn.

Base URLs


Functions

File Extension Logic

  • If the hash starts with a_ - the extension is always gif (animated resource).
  • Otherwise CdnOptions.extension is used, or "png" by default.

Formatters

Text utilities from fluxer_util::formatters.

truncate

Truncates a string to max_len characters. If the string is longer - the last character is replaced with (U+2026).
Use truncate before passing user-provided data into MessagePayload::content or EmbedBuilder fields to avoid panics when exceeding limits.

escape_markdown

Escapes Markdown characters: *, _, ~, `, |, >, #.

format_color

Formats an RGB integer into a hex string of the form #RRGGBB. Clamps values above 0xFFFFFF.

format_timestamp

Formats a Unix timestamp (in seconds) into a Fluxer time tag <t:timestamp:style>.

Tenor

Utilities for working with Tenor GIF links from fluxer_util::tenor.

is_tenor_url

Returns true if the URL is a Tenor link. Recognizes the following formats:
  • https://tenor.com/view/...
  • https://tenor.com/embed/...
  • https://media.tenor.com/...

extract_tenor_id

Extracts the numeric GIF ID from a Tenor link. Returns None if the ID is not found or is not a number.

tenor_media_url

Builds a direct link to the GIF file by ID:

resolve_tenor_to_image_url

Combines extract_tenor_id and tenor_media_url. Accepts a Tenor share/embed URL and returns a direct link to the GIF. Returns None if the URL is not recognized.

Resolvers

Helper functions from fluxer_util::resolvers for working with colors.

resolve_color

Parses a hex color string into an RGB integer. Accepts "#RRGGBB" and "RRGGBB" formats.

resolve_color_rgb

Converts R, G, B components into an RGB integer.

Emoji

Utilities from fluxer_util::emoji for emoji formatting.

format_emoji

Formats an emoji into a string for passing to API routes.

parse_emoji_str

Parses an emoji string into its components (name, id, animated).