Documentation
¶
Overview ¶
Package hyphae manages hypha storage and hypha types.
Index ¶
- func AreFreeNames(hyphaNames ...string) (firstFailure string, ok bool)
- func Count() int
- func DeleteHypha(h ExistingHypha)
- func FetchMycomarkupFile(h Hypha) (string, error)
- func FilterHyphaeWithText(src chan ExistingHypha) chan ExistingHypha
- func Index(path string)
- func Insert(h ExistingHypha) (madeNewRecord bool)
- func IsValidName(hyphaName string) bool
- func PathographicSort(src chan string) <-chan string
- func RenameHyphaTo(h ExistingHypha, newName string, replaceName func(string) string)
- func ResetCount()
- func WriteToMycoFile(h ExistingHypha, data []byte) error
- func YieldExistingHyphae() chan ExistingHypha
- type EmptyHypha
- type ExistingHypha
- type Hypha
- type MediaHypha
- type TextualHypha
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreFreeNames ¶
AreFreeNames checks if all given `hyphaNames` are not taken. If they are not taken, `ok` is true. If not, `firstFailure` is the name of the first met hypha that is not free.
func Count ¶
func Count() int
Count how many hyphae there are. This is a O(1), the number of hyphae is stored in memory.
func DeleteHypha ¶
func DeleteHypha(h ExistingHypha)
DeleteHypha deletes the hypha from the storage.
func FetchMycomarkupFile ¶
FetchMycomarkupFile tries to read text file of the given hypha. If there is no file, empty string is returned.
TODO: Get rid of this function.
func FilterHyphaeWithText ¶
func FilterHyphaeWithText(src chan ExistingHypha) chan ExistingHypha
FilterHyphaeWithText filters the source channel and yields only those hyphae than have text parts.
func Index ¶
func Index(path string)
Index finds all hypha files in the full `path` and saves them to the hypha storage.
func Insert ¶
func Insert(h ExistingHypha) (madeNewRecord bool)
Insert inserts the hypha into the storage, possibly overwriting the previous hypha with the same name. Count incrementation is done if needed. You cannot insert an empty hypha.
func IsValidName ¶
IsValidName checks for invalid characters and path traversals.
func PathographicSort ¶
PathographicSort sorts paths inside the source channel, preserving the path tree structure
func RenameHyphaTo ¶
func RenameHyphaTo(h ExistingHypha, newName string, replaceName func(string) string)
RenameHyphaTo renames a hypha and renames stored filepaths as needed. The actual files are not moved, move them yourself.
func ResetCount ¶
func ResetCount()
ResetCount sets the value of hyphae count to zero. Use when reloading hyphae.
func WriteToMycoFile ¶
func WriteToMycoFile(h ExistingHypha, data []byte) error
func YieldExistingHyphae ¶
func YieldExistingHyphae() chan ExistingHypha
YieldExistingHyphae iterates over all hyphae and yields all existing ones.
Types ¶
type EmptyHypha ¶
EmptyHypha is a hypha that does not exist and is not stored anywhere. You get one when querying for a hypha that was not created before.
func (*EmptyHypha) CanonicalName ¶
func (e *EmptyHypha) CanonicalName() string
type ExistingHypha ¶
ExistingHypha is not EmptyHypha. *MediaHypha and *TextualHypha implement this interface.
type Hypha ¶
type Hypha interface { sync.Locker // CanonicalName returns the canonical name of the hypha. // // util.CanonicalName(h.CanonicalName()) == h.CanonicalName() CanonicalName() string }
Hypha is the hypha you know and love.
type MediaHypha ¶
func ExtendEmptyToMedia ¶
func ExtendEmptyToMedia(e *EmptyHypha, mediaFilePath string) *MediaHypha
ExtendEmptyToMedia returns a new media hypha with the same name as the given empty hypha. The created hypha is not stored yet.
func ExtendTextualToMedia ¶
func ExtendTextualToMedia(t *TextualHypha, mediaFilePath string) *MediaHypha
ExtendTextualToMedia returns a new media hypha with the same name and text file as the given textual hypha. The new hypha is not stored yet.
func (*MediaHypha) CanonicalName ¶
func (m *MediaHypha) CanonicalName() string
func (*MediaHypha) HasTextFile ¶
func (m *MediaHypha) HasTextFile() bool
func (*MediaHypha) MediaFilePath ¶
func (m *MediaHypha) MediaFilePath() string
func (*MediaHypha) SetMediaFilePath ¶
func (m *MediaHypha) SetMediaFilePath(newPath string)
func (*MediaHypha) TextFilePath ¶
func (m *MediaHypha) TextFilePath() string
type TextualHypha ¶
TextualHypha is a hypha with text, and nothing else. An article, a note, a poem, whatnot.
func ExtendEmptyToTextual ¶
func ExtendEmptyToTextual(e *EmptyHypha, mycoFilePath string) *TextualHypha
ExtendEmptyToTextual returns a new textual hypha with the same name as the given empty hypha. The created hypha is not stored yet.
func ShrinkMediaToTextual ¶
func ShrinkMediaToTextual(m *MediaHypha) *TextualHypha
func (*TextualHypha) CanonicalName ¶
func (t *TextualHypha) CanonicalName() string
func (*TextualHypha) HasTextFile ¶
func (t *TextualHypha) HasTextFile() bool
func (*TextualHypha) TextFilePath ¶
func (t *TextualHypha) TextFilePath() string