Skip to main content

HwpxReader

Struct HwpxReader 

Source
pub struct HwpxReader { /* private fields */ }
Expand description

HWPX ZIP 컨테이너 리더

Implementations§

Source§

impl HwpxReader

Source

pub fn open(data: &[u8]) -> Result<Self, HwpxError>

ZIP 아카이브를 연다.

Source

pub fn read_file(&mut self, path: &str) -> Result<String, HwpxError>

지정한 경로의 파일을 UTF-8 문자열로 읽는다.

엔트리 압축 해제 크기는 MAX_XML_SIZE로 제한된다.

[Issue #1932] UTF-8 이 부분 손상된 실문서(통계청 보도자료 계열 — header.xml 선두부 invalid byte)를 한글은 정상 열람하므로, 엄격 변환 실패 시 관용(lossy) 디코딩으로 폴백한다 (손상 바이트는 U+FFFD 치환, 경고 로그). 문서 전체를 버리는 종전 동작은 한글 대비 과잉 거부였다.

Source

pub fn read_file_bytes(&mut self, path: &str) -> Result<Vec<u8>, HwpxError>

지정한 경로의 파일을 바이트 배열로 읽는다.

엔트리 압축 해제 크기는 MAX_BINDATA_SIZE로 제한된다.

Source

pub fn read_file_bytes_limited( &mut self, path: &str, max_bytes: usize, ) -> Result<Vec<u8>, HwpxError>

지정한 경로의 파일을 max_bytes 바이트까지만 압축 해제한다.

Source

pub fn file_size_limited( &mut self, path: &str, max_bytes: usize, ) -> Result<usize, HwpxError>

ZIP central directory의 비압축 크기만 상한과 비교한다.

BinData 존재 여부·길이처럼 실제 바이트가 필요 없는 질의가 ZIP payload를 materialize하지 않도록 쓴다. 실제 읽기는 반드시 Self::read_file_bytes_limited를 다시 거치므로, 손상된 size 메타데이터를 신뢰해 상한을 우회하지 않는다.

Source

pub fn raw_deflated_entry(&mut self, path: &str) -> Option<DeflatedZipEntry>

deflate 로 저장된 엔트리의 압축 바이트와 CRC-32·비압축 크기 (압축 해제 없음).

deflate 가 아니거나 압축 크기가 MAX_BINDATA_SIZE 를 넘으면 None 이다.

Source

pub fn file_names(&self) -> Vec<String>

아카이브 내 파일 목록을 반환한다.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more