Struct radicle_git_ext::tree::Tree

source ·
pub struct Tree<'a>(/* private fields */);
Expand description

A simplified representation of a git tree, intended mainly to be created from literals.

§Example

use radicle_git_ext::tree::{Tree, blob};

let my_tree = vec![
    ("README", blob(b"awe")),
    ("src", vec![("main.rs", blob(b"fn main() {}"))].into_iter().collect()),
]
.into_iter()
.collect::<Tree>();

assert_eq!(
    format!("{:?}", my_tree),
    "Tree(\
        {\
            \"README\": Blob(\
                [\
                    97, \
                    119, \
                    101\
                ]\
            ), \
            \"src\": Tree(\
                Tree(\
                    {\
                        \"main.rs\": Blob(\
                            [\
                                102, \
                                110, \
                                32, \
                                109, \
                                97, \
                                105, \
                                110, \
                                40, \
                                41, \
                                32, \
                                123, \
                                125\
                            ]\
                        )\
                    }\
                )\
            )\
        }\
    )"
)

Implementations§

source§

impl Tree<'_>

source

pub fn write(&self, repo: &Repository) -> Result<Oid, Error>

Trait Implementations§

source§

impl<'a> Clone for Tree<'a>

source§

fn clone(&self) -> Tree<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Tree<'a>

source§

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

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

impl<'a> From<BTreeMap<Cow<'a, str>, Node<'a>>> for Tree<'a>

source§

fn from(map: BTreeMap<Cow<'a, str>, Node<'a>>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Tree<'a>> for Node<'a>

source§

fn from(tree: Tree<'a>) -> Self

Converts to this type from the input type.
source§

impl<'a, K, N> FromIterator<(K, N)> for Tree<'a>
where K: Into<Cow<'a, str>>, N: Into<Node<'a>>,

source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = (K, N)>,

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Tree<'a>

§

impl<'a> RefUnwindSafe for Tree<'a>

§

impl<'a> Send for Tree<'a>

§

impl<'a> Sync for Tree<'a>

§

impl<'a> Unpin for Tree<'a>

§

impl<'a> UnwindSafe for Tree<'a>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.