Skip to main content

Metadata

Struct Metadata 

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

Метаданные файла или каталога: набор записей «вид, значение».

Implementations§

Source§

impl Metadata

Source

pub fn equivalent(&self, other: &Self) -> Result<bool, FsError>

Сравнивает наборы так, как это делает GNUnet: имена модулей и типы MIME в сравнении не участвуют.

Source

pub fn merge(&mut self, other: &Self) -> Result<(), FsError>

Добавляет записи из other, которых здесь ещё нет.

Source

pub fn delete( &mut self, meta_type: MetaType, data: Option<&[u8]>, ) -> Result<bool, FsError>

Удаляет записи вида meta_type.

При data = None удаляются все записи этого вида, иначе только запись с таким значением (текстовое значение передаётся вместе с завершающим нулевым байтом). Возвращает true, если что-то удалено.

Source

pub fn clear(&mut self)

Удаляет все записи.

Source

pub fn add_publication_date(&mut self) -> Result<(), FsError>

Добавляет запись с текущей датой как датой публикации.

Source

pub fn get_first_by_types(&self, types: &[MetaType]) -> Option<String>

Первое текстовое значение одного из видов types, в порядке их перечисления.

Source

pub fn is_directory(&self) -> Result<Option<bool>, FsError>

Описывают ли метаданные каталог: Some(true) — да, Some(false) — нет, None — тип MIME не указан.

Source

pub fn make_directory(&mut self) -> Result<(), FsError>

Помечает метаданные как метаданные каталога (тип MIME каталога GNUnet).

Source

pub fn suggest_filename(&self) -> Result<Option<String>, FsError>

Предлагает имя файла по метаданным; None, если подходящих записей нет.

Source

pub fn serialized_size(&self) -> Result<usize, FsError>

Размер двоичного представления в байтах.

Source

pub fn serialize( &self, max_size: usize, options: MetadataSerializationOptions, ) -> Result<Vec<u8>, FsError>

Двоичное представление метаданных, не превышающее max_size байт.

Source

pub fn deserialize(bytes: &[u8]) -> Result<Self, FsError>

Восстанавливает метаданные из двоичного представления.

Source§

impl Metadata

Source

pub fn insert_entry(&mut self, entry: MetadataEntry) -> Result<bool, FsError>

Добавляет запись со всеми полями, включая имя модуля libextractor. Возвращает false, если запись с таким видом, форматом и значением уже есть.

Source

pub fn get_by_type( &self, meta_type: MetaType, ) -> Result<Option<String>, FsError>

Текстовое значение данного вида в том порядке выбора, который применяет GNUnet.

Source

pub fn get_by_types( &self, types: &[MetaType], ) -> Result<Option<String>, FsError>

Текстовое значение одного из видов types в порядке выбора GNUnet.

Source§

impl Metadata

Source

pub const MIMETYPE: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_MIMETYPE

Тип MIME.

Source

pub const FILENAME: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_FILENAME

Имя файла.

Source

pub const COMMENT: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_COMMENT

Комментарий.

Source

pub const TITLE: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_TITLE

Заголовок.

Source

pub const AUTHOR_NAME: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_AUTHOR_NAME

Имя автора.

Source

pub const DESCRIPTION: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_DESCRIPTION

Описание.

Source

pub const KEYWORDS: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_KEYWORDS

Ключевые слова.

Source

pub const THUMBNAIL: MetaType = gnunet_sys::EXTRACTOR_MetaType_EXTRACTOR_METATYPE_THUMBNAIL

Миниатюра: двоичная запись с типом MIME image/…. Её находит thumbnail.

Source

pub fn new() -> Self

Пустой набор.

Source

pub fn entries(&self) -> &[MetadataEntry]

Все записи.

Source

pub fn insert_text( &mut self, meta_type: MetaType, value: impl AsRef<str>, ) -> Result<(), FsError>

Добавляет текстовую запись.

Source

pub fn insert_binary( &mut self, meta_type: MetaType, mime_type: &str, data: &[u8], ) -> Result<(), FsError>

Добавляет двоичную запись с типом MIME, например миниатюру.

Source

pub fn insert( &mut self, meta_type: MetaType, format: MetaFormat, data_mime_type: Option<&str>, data: &[u8], ) -> Result<(), FsError>

Добавляет запись с явным указанием формата.

Source

pub fn get_first(&self, meta_type: MetaType) -> Option<String>

Первое текстовое значение данного вида.

Source

pub fn get_all(&self, meta_type: MetaType) -> Vec<String>

Все текстовые значения данного вида.

Source

pub fn thumbnail(&self) -> Option<Vec<u8>>

Миниатюра: двоичная запись с типом MIME image/…. Предпочитается запись вида THUMBNAIL, иначе берётся первая подходящая.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Metadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Metadata

Source§

fn default() -> Metadata

Returns the “default value” for a type. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.