Expand description
§Endianness
PSD is big-endian. Upstream calls DataView.getInt16/getUint16/getInt32/ getUint32/getFloat32/getFloat64 with the littleEndian argument either
omitted or explicitly false (e.g. getInt16(off, false)), which means
big-endian. The few *LE variants pass true. This port reproduces that:
all default readers use from_be_bytes, the _le variants use
from_le_bytes.
§Error strategy
Upstream throws Error in a handful of places (checkSignature,
readSection overflow, warnOrThrow when strict, the >100MB guard in
readBytes). It also reads past the end of a slice in some “broken file”
recovery paths. We model fallible operations as Result<T, ReadError> with
a small crate-local ReadError enum, returned consistently from every
primitive that can fail. This is preferred over panicking because callers
(the future document orchestration) need to distinguish recoverable from
fatal conditions, mirroring upstream’s strict/warnOrThrow split.
Structs§
- Decode
Target - Pixel storage backing a
PixelDataduring decode, tracking bit depth so the channel codecs can write at the correct stride. - PsdReader
- Состояние низкоуровневого ридера (зеркало TS
interface PsdReader extends ReadOptions).
Enums§
- Read
Error - Ошибки низкоуровневого ридера (зеркало
throw new Error(...)из upstream).
Functions§
- check_
signature - Зеркало
checkSignature(reader, a, b?). - peek_
uint8 - Зеркало
peekUint8— читает без сдвига курсора. - peek_
uint32 - Хелпер
peekUint32— задача упоминает его наличие; в upstream отдельной функции нет, но peek-семантика (чтение без сдвига курсора) полезна и согласуется сpeekUint8. Big-endian. - read_
ascii_ string - Зеркало
readAsciiString(reader, length). - read_
bytes - Зеркало
readBytes(reader, length). - read_
bytes_ slice - Zero-copy вариант чтения байтов: возвращает под-срез исходного буфера.
- read_
color - Consolidated
readColor. NOTE (see report):effects_helpers,image_resources,additional_info::adjustment_keys, andadditional_info::misc_keyseach keep a LOCAL copy of this function (they cannot reach reader-internal helpers). Those should switch to this in a later cleanup task; not edited now. - read_
data_ raw - Mirror
readDataRaw. Down-converts 16/32-bit samples to 8-bit (top byte). - read_
data_ rle - Mirror
readDataRLE(PackBits). Writes one byte per sample to the 8-bit RGBA target. For >8 bit depths the source is still byte-stream PackBits, so we keep upstream’s byte semantics (the upstream RLE path also writes bytes). - read_
data_ zip - Mirror
readDataZip(zlib via flate2). - read_
fixed_ point32 - Зеркало
readFixedPoint32— 32-битное число с фиксированной точкой 16.16. - read_
fixed_ point_ path32 - Зеркало
readFixedPointPath32— 32-битное число с фиксированной точкой 8.24. - read_
float32 - read_
float64 - read_
int8 - Upstream имеет
readInt8? Нет отдельной функции, но задание просит её — реализуем через интерпретацию байта как знакового (DataView.getInt8). - read_
int16 - read_
int32 - read_
int32_ le - Зеркало
readInt32LE(little-endian). - read_
pascal_ string - Зеркало
readPascalString(reader, padTo). - read_
pattern - Consolidated
readPattern. NOTE (see report):abr.rsandsmart_object_keys.rshold local copies; they should switch to this later. - read_
psd - High-level entry point. Mirror of upstream
readPsd(reader, readOptions), but takes a byte slice + options and builds aPsdReaderinternally. - read_
psd_ from_ reader - Mirror of upstream
readPsdoperating on an existing reader (options must already be set on the reader, as upstream does viaObject.assign). - read_
section - Зеркало
readSection<T>(reader, round, func, skipEmpty = true, eightBytes = false). - read_
short_ string - Зеркало приватной
readShortString(reader, length). - read_
signature - Зеркало
readSignature(reader)— 4-байтовая подпись. - read_
uint8 - read_
uint16 - read_
uint32 - read_
uint16_ le - Зеркало
readUint16LE(little-endian). - read_
unicode_ string - Зеркало
readUnicodeString(reader)— uint32 длина (в code unit’ах), затем строка. - read_
unicode_ string_ with_ length - Зеркало
readUnicodeStringWithLength(reader, length)(big-endian uint16 code units). - read_
unicode_ string_ with_ length_ le - Зеркало
readUnicodeStringWithLengthLE(little-endian uint16 code units). - skip_
bytes - Зеркало
skipBytes(reader, count). - valid_
signature_ at - Зеркало
validSignatureAt(reader, offset)—8BIM/8B64по абсолютному offset. - warn_
or_ throw - Зеркало
warnOrThrow(reader, message).
Type Aliases§
- Read
Result - Результат операций ридера.