Entity tags (Effect's Etag): Weak / Strong values and the
Generator service that makes them for files.
Values#
| Attribute | Type | Description |
|---|---|---|
layer | Layer[Generator] | Strong tags. |
layer_weak | Layer[Generator] | Weak tags. |
Types#
| Type | Definition | Description |
|---|---|---|
Etag | type Etag = Weak | Strong |
Classes#
Functions#
to_string#
to_string(etag) -> strThe header value: W/"value" or "value".
| Parameter | Type | Description |
|---|---|---|
etag | Etag |
Returns str
def to_string(etag: Etag) -> str:
"""The header value: ``W/"value"`` or ``"value"``."""
match etag:
case Weak(value):
return f'W/"{value}"'
case Strong(value):
return f'"{value}"'value_from_file_info#
value_from_file_info(info) -> str<size>-<mtime ms> in hex (0 without an mtime).
| Parameter | Type | Description |
|---|---|---|
info | FileInfo |
Returns str
def value_from_file_info(info: FileInfo) -> str:
"""``<size>-<mtime ms>`` in hex (``0`` without an mtime)."""
mtime = "0" if info.mtime is None else format(_milliseconds(info.mtime), "x")
return f"{int(info.size):x}-{mtime}"value_from_file_web#
value_from_file_web(file) -> str| Parameter | Type | Description |
|---|---|---|
file | FileLike |
Returns str
def value_from_file_web(file: FileLike) -> str:
return f"{file.size:x}-{_milliseconds(file.last_modified):x}"