stof_github

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<()>

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<(), Error>

Content type import.
Source§

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

String import.
Source§

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

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

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

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

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

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> 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, 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,

Source§

impl<T> MaybeSendSync for T