Struct GitHubFormat

Source
pub struct GitHubFormat {
    pub repo_id: String,
    pub owner: String,
    pub repo: String,
    pub headers: HashMap<String, String>,
    pub agent: Agent,
}
Expand description

Stof GitHub Format.

Fields§

§repo_id: String

Format Repo ID. Ex. “formata” means format is “github:formata”.

§owner: String

Repository owner.

§repo: String

Repository name.

§headers: HashMap<String, String>

Headers.

§agent: Agent

Agent.

Implementations§

Source§

impl GitHubFormat

Source

pub fn new(repo: &str, owner: &str) -> Self

Create a new GitHub Format.

Source

pub fn url(&self, path: &str) -> String

The URL for a request into this GitHub repository.

Source

pub fn get(&self, file_path: &str) -> Result<String>

Get the string contents for a file path into this GitHub repository.

Trait Implementations§

Source§

impl Format for GitHubFormat

Source§

fn format(&self) -> String

How this format will be accessed in Stof. For example, if repo_id is “formata”, using this library would be the format identifier “github:formata”.

import github:formata "myfile.stof" as Import;

Source§

fn file_import( &self, pid: &str, doc: &mut SDoc, format: &str, full_path: &str, extension: &str, as_name: &str, ) -> Result<(), SError>

The GitHub format only allows a file import. Gets the contents of the file at a path in this GitHub repo, then imports it as a string using the file extension. Will error if a Format with the requested file extension is not available in the doc.

Source§

fn content_type(&self) -> String

Content type. Used when sending documents over the wire, etc…
Source§

fn header_import( &self, pid: &str, doc: &mut SDoc, content_type: &str, bytes: &mut Bytes, as_name: &str, ) -> Result<(), SError>

Content type import.
Source§

fn string_import( &self, pid: &str, doc: &mut SDoc, src: &str, as_name: &str, ) -> Result<(), SError>

String import.
Source§

fn export_string( &self, pid: &str, doc: &SDoc, node: Option<&SNodeRef>, ) -> Result<String, SError>

Export document into a string (human readable string).
Source§

fn export_min_string( &self, pid: &str, doc: &SDoc, node: Option<&SNodeRef>, ) -> Result<String, SError>

Export document into a string (minified string).
Source§

fn export_bytes( &self, pid: &str, doc: &SDoc, node: Option<&SNodeRef>, ) -> Result<Bytes, SError>

Export document into bytes.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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